Package org.tailormap.api.prometheus
Class PrometheusResultProcessor
java.lang.Object
org.tailormap.api.prometheus.PrometheusResultProcessor
- All Implemented Interfaces:
TagNames
-
Field Summary
Fields inherited from interface org.tailormap.api.prometheus.TagNames
APP_ID_REPLACE_TOKEN, METRICS_APP_ID_TAG, METRICS_APP_LAYER_ID_TAG, METRICS_APP_LAYER_NAME_TAG, METRICS_APP_LAYER_TITLE_TAG, METRICS_APP_NAME_TAG, METRICS_APP_REQUEST_COUNTER_NAME, METRICS_APP_TYPE_TAG, NUMBER_OF_DAYS_REPLACE_TOKEN
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprocessPrometheusResultsForApplicationLayers
(com.fasterxml.jackson.databind.JsonNode root) Processes the JSON response from a Prometheus query and groups the results byTagNames.METRICS_APP_LAYER_ID_TAG
.processPrometheusResultsForApplications
(com.fasterxml.jackson.databind.JsonNode root) Processes the JSON response from a Prometheus query and groups the results byTagNames.METRICS_APP_ID_TAG
.com.fasterxml.jackson.databind.node.ArrayNode
processPrometheusResultsToJsonArray
(com.fasterxml.jackson.databind.JsonNode jsonResponse1, com.fasterxml.jackson.databind.JsonNode jsonResponse2) Merges two Prometheus JSON responses and processes the results into an ArrayNode.
-
Constructor Details
-
PrometheusResultProcessor
public PrometheusResultProcessor()
-
-
Method Details
-
processPrometheusResultsForApplications
public Collection<Map<String,String>> processPrometheusResultsForApplications(com.fasterxml.jackson.databind.JsonNode root) Processes the JSON response from a Prometheus query and groups the results byTagNames.METRICS_APP_ID_TAG
. Each appId will have a map of metrics, where the key is the metric type (e.g., "total", "lastUpdated") and the value is the metric value. Additionally, the appName is included in the map for each appId.- Parameters:
root
- the root JSON node containing the Prometheus query results (expected structure: root.data.result) where each result has a "metric" object with "appId", "type", and "value" fields, and a "value" array where the second element is the metric value. The "metric" object may also contain "appName".- Returns:
- a map where the key is the appId and the value is another map containing metric types as keys and their corresponding values. The inner map also includes the appName under the key "appName". If an appId has no metrics, it will not be included in the results.
- See Also:
-
processPrometheusResultsForApplicationLayers
public Collection<Map<String,String>> processPrometheusResultsForApplicationLayers(com.fasterxml.jackson.databind.JsonNode root) Processes the JSON response from a Prometheus query and groups the results byTagNames.METRICS_APP_LAYER_ID_TAG
. Each appLayerId will have a map of metrics, where the key is the metric type (e.g., "total", "lastUpdated") and the value is the metric value. Additionally, the appName is included in the map for each appId.- Parameters:
root
- the root JSON node containing the Prometheus query results (expected structure: root.data.result) where each result has a "metric" object with "appId", "type", and "value" fields, and a "value" array where the second element is the metric value. The "metric" object may also contain "appName".- Returns:
- a map where the key is the appLayerId and the value is another map containing metric types as keys and their corresponding values. The inner map also includes the appName under the key "appName". If an appId has no metrics, it will not be included in the results.
- See Also:
-
processPrometheusResultsToJsonArray
public com.fasterxml.jackson.databind.node.ArrayNode processPrometheusResultsToJsonArray(com.fasterxml.jackson.databind.JsonNode jsonResponse1, com.fasterxml.jackson.databind.JsonNode jsonResponse2) throws IOException Merges two Prometheus JSON responses and processes the results into an ArrayNode. Each appId will have a map of metrics, where the key is the metric type (e.g., "total", "lastUpdated") and the value is the metric value.- Parameters:
jsonResponse1
- the first JSON response from a Prometheus queryjsonResponse2
- the second JSON response from a Prometheus query- Returns:
- an ArrayNode containing maps of metrics for each appId
- Throws:
IOException
- if there is an error processing the JSON responses
-