Schnittstelle PrometheusHTTPApi
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidRemoves deleted datacreateSnapshot(@Nullable Boolean skipHead) Creates Snapshot of current datavoiddeleteSeries(@NotNull List<String> match, @Nullable String start, @Nullable String end) Deletes selected dataevaluateQueryInstant(@NotNull String query, @Nullable String time, @Nullable String timeout) Evaluates instant queryevaluateQueryRange(@NotNull String query, @Nullable String start, @Nullable String end, @Nullable String step, @Nullable String timeout) Evaluates query over range of time.metricMetadataReadResponse(@NotNull Integer limit, @Nullable String metric) Returns metric metadataReturns current alertmanager discoveryReturns active alertsreadLabelNames(@Nullable String start, @Nullable String end, @Nullable List<String> match) Returns label namesreadLabelValues(@NotNull String labelName, @NotNull String start, @Nullable String end, @Nullable List<String> match) Returns label valuesreadQueryExemplars(@NotNull String query, @Nullable String start, @Nullable String end) Returns list of ExemplarsReturns currently loaded rulesreadSeries(@NotNull List<String> match, @Nullable String start, @Nullable String end) Returns time seriesReturns build informationReturns configuration filevoidReturns flag valuesReturns runtime infoReturns statistics about TSBDReturns info about WAL replay.readTargetMetadata(@Nullable String matchTarget, @Nullable String metric, @Nullable Integer limit) Returns target metadatareadTargets(@Nullable String state) Returns current target discovery.
-
Methodendetails
-
cleanTombstones
void cleanTombstones()Removes deleted dataCleanTombstones removes the deleted data from disk and cleans up the existing tombstones. This can be used after deleting series to free up space.
-
createSnapshot
Creates Snapshot of current dataSnapshot creates a snapshot of all current data into "snapshots/<datetime>-<rand>" under the TSDB's data directory and returns the directory as response. It will optionally skip snapshotting data that is only present in the head block, and which has not yet been compacted to disk.
- Parameter:
skipHead- Skip data present in the head block. Optional. (optional)
-
deleteSeries
void deleteSeries(@NotNull @NotNull List<String> match, @Nullable @Nullable String start, @Nullable @Nullable String end) Deletes selected dataDeleteSeries deletes data for a selection of series in a time range. The actual data still exists on disk and is cleaned up in future compactions or can be explicitly cleaned up by hitting the [Clean Tombstones](https://prometheus.io/docs/prometheus/latest/querying/api/#clean-tombstones) endpoint. **NOTE:** This endpoint marks samples from series as deleted, but will not necessarily prevent associated series metadata from still being returned in metadata queries for the affected time range (even after cleaning tombstones). The exact extent of metadata deletion is an implementation detail that may change in the future.
- Parameter:
match- Repeated label matcher argument that selects the series to delete. At least one match[] argument must be provided. (required)start- Start timestamp. Optional and defaults to minimum possible time. (optional)end- End timestamp. Optional and defaults to maximum possible time. Not mentioning both start and end times would clear all the data for the matched series in the database. (optional)
-
evaluateQueryInstant
QueryDataReadResponse evaluateQueryInstant(@NotNull @NotNull String query, @Nullable @Nullable String time, @Nullable @Nullable String timeout) Evaluates instant queryThe following endpoint evaluates an instant query at a single point in time You can URL-encode these parameters directly in the request body by using the "POST" method and "Content-Type: application/x-www-form-urlencoded" header. This is useful when specifying a large query that may breach server-side URL character limits. The data section of the query result has the following format " { "resultType": "matrix" | "vector" | "scalar" | "string", "result": <value> } " "<value>" refers to the query result data, which has varying formats depending on the "resultType". See the [expression query result formats](https://prometheus.io/docs/prometheus/latest/querying/api/#expression-query-result-formats).
- Parameter:
query- Prometheus expression query string. (required)time- Evaluation timestamp. Optional. The current server time is used if the time parameter is omitted. (optional)timeout- Evaluation timeout. Optional. Defaults to and is capped by the value of the "-query.timeout" flag. (optional)
-
evaluateQueryRange
ResponseQueryRange evaluateQueryRange(@NotNull @NotNull String query, @Nullable @Nullable String start, @Nullable @Nullable String end, @Nullable @Nullable String step, @Nullable @Nullable String timeout) Evaluates query over range of time.The following endpoint evaluates an expression query over a range of time You can URL-encode these parameters directly in the request body by using the "POST" method and "Content-Type: application/x-www-form-urlencoded" header. This is useful when specifying a large query that may breach server-side URL character limits. The data section of the query result has the following format " { "resultType": "matrix", "result": <value> } " For the format of the "<value>" placeholder, see the [range-vector result format](https://prometheus.io/docs/prometheus/latest/querying/api/#range-vectors).
- Parameter:
query- Prometheus expression query string. (required)start- Start timestamp. (optional)end- End timestamp. (optional)step- Query resolution step width in "duration" format or float number of seconds. (optional)timeout- Evaluation timeout. Optional. Defaults to and is capped by the value of the "-query.timeout" flag. (optional)
-
metricMetadataReadResponse
MetadataReadResponse metricMetadataReadResponse(@NotNull @NotNull Integer limit, @Nullable @Nullable String metric) Returns metric metadataIt returns metadata about metrics currently scrapped from targets. However, it does not provide any target information. This is considered experimental and might change in the future. The data section of the query result consists of an object where each key is a metric name and each value is a list of unique metadata objects, as exposed for that metric name across all targets.
- Parameter:
limit- Maximum number of metrics to return. (required)metric- A metric name to filter metadata for. All metric metadata is retrieved if left empty. (optional)
-
readAlertManagers
AlertManagerReadResponse readAlertManagers()Returns current alertmanager discoveryReturns an overview of the current state of the Prometheus alertmanager discovery Both the active and dropped Alertmanagers are part of the response.
-
readAlerts
AlertReadResponse readAlerts()Returns active alertsThe /alerts endpoint returns a list of all active alerts. As the /alerts endpoint is fairly new, it does not have the same stability guarantees as the overarching API v1.
-
readLabelNames
LabelNamesReadResponse readLabelNames(@Nullable @Nullable String start, @Nullable @Nullable String end, @Nullable @Nullable List<String> match) Returns label namesThe following endpoint returns a list of label names. The `data` section of the JSON response is a list of string label names. **NOTE:** These API endpoints may return metadata for series for which there is no sample within the selected time range, and/or for series whose samples have been marked as deleted via the deletion API endpoint. The exact extent of additionally returned series metadata is an implementation detail that may change in the future.
- Parameter:
start- Start timestamp. (optional)end- End timestamp. (optional)match- Repeated series selector argument that selects the series from which to read the label values. Optional. (optional)
-
readLabelValues
LabelValuesReadResponse readLabelValues(@NotNull @NotNull String labelName, @NotNull @NotNull String start, @Nullable @Nullable String end, @Nullable @Nullable List<String> match) Returns label valuesThe following endpoint returns a list of label values for a provided label name The `data` section of the JSON response is a list of string label values. **NOTE:** These API endpoints may return metadata for series for which there is no sample within the selected time range, and/or for series whose samples have been marked as deleted via the deletion API endpoint. The exact extent of additionally returned series metadata is an implementation detail that may change in the future.
- Parameter:
labelName- Label name. (required)start- Start timestamp. (required)end- End timestamp. (optional)match- Repeated series selector argument that selects the series from which to read the label values. (optional)
-
readQueryExemplars
@Experimental QueryExemplarsReadResponse readQueryExemplars(@NotNull @NotNull String query, @Nullable @Nullable String start, @Nullable @Nullable String end) Returns list of ExemplarsThis is <b>experimental</b> and might change in the future. The following endpoint returns a list of exemplars for a valid PromQL query for a specific time range
- Parameter:
query- Prometheus expression query string. (required)start- Start timestamp. (optional)end- End timestamp. (optional)
-
readRules
Returns currently loaded rulesThe "/rules" API endpoint returns a list of alerting and recording rules that are currently loaded. In addition it returns the currently active alerts fired by the Prometheus instance of each alerting rule. As the "/rules" endpoint is fairly new, it does not have the same stability guarantees as the overarching API v1.
- Parameter:
type- Return only the alerting rules (e.g. "type=alert") or the recording rules (e.g. "type=record"). When the parameter is absent or empty, no filtering is done. (optional)
-
readSeries
List<QueryDataResultMetric> readSeries(@NotNull @NotNull List<String> match, @Nullable @Nullable String start, @Nullable @Nullable String end) Returns time seriesThe following endpoint returns the list of time series that match a certain label set. You can URL-encode these parameters directly in the request body by using the "POST" method and "Content-Type: application/x-www-form-urlencoded" header. This is useful when specifying a large or dynamic number of series selectors that may breach server-side URL character limits. The "data" section of the query result consists of a list of objects that contain the label name/value pairs which identify each series.
- Parameter:
match- Repeated series selector argument that selects the series to return. At least one "match[]" argument must be provided. (required)start- Start timestamp. Optional. (optional)end- End timestamp. Optional. (optional)
-
readServerBuildInfo
PrometheusBuildInfoReadResponse readServerBuildInfo()Returns build informationThe following endpoint returns various build information properties about the Prometheus server.
-
readServerConfig
PrometheusConfigReadResponse readServerConfig()Returns configuration fileThe following endpoint returns currently loaded configuration file The config is returned as dumped YAML file. Due to limitation of the YAML library, YAML comments are not included.
-
readServerFlags
void readServerFlags()Returns flag valuesThe following endpoint returns flag values that Prometheus was configured with.
-
readServerRuntimeInfo
RuntimeInfoResponse readServerRuntimeInfo()Returns runtime infoThe following endpoint returns various runtime information properties about the Prometheus server The returned values are of different types, depending on the nature of the runtime property --- **NOTE:** The exact returned runtime properties may change without notice between Prometheus versions. --- New in v2.14
-
readServerTSDBStatus
TsdbStatusReadResponse readServerTSDBStatus()Returns statistics about TSBDThe following endpoint returns various cardinality statistics about the Prometheus TSDB Response Data --- **headStats:** This provides the following data about the head block of the TSDB: >**numSeries:** The number of series. **chunkCount:** The number of chunks. **minTime:** The current minimum timestamp in milliseconds. **maxTime:** The current maximum timestamp in milliseconds. **seriesCountByMetricName:** This will provide a list of metrics names and their series count. **labelValueCountByLabelName:** This will provide a list of the label names and their value count. **memoryInBytesByLabelName:** This will provide a list of the label names and memory used in bytes. Memory usage is calculated by adding the length of all values for a given label name. **seriesCountByLabelPair:** This will provide a list of label value pairs and their series count.
-
readServerWALReplayStatus
WalReplayStatusReadResponse readServerWALReplayStatus()Returns info about WAL replay.The following endpoint returns information about the WAL replay Response Data --- **read:** The number of segments replayed so far. **total:** The total number segments needed to be replayed. **progress:** The progress of the replay (0 - 100%). **state:** The state of the replay. **Possible states:** - **waiting:** Waiting for the replay to start. - **in progress:** The replay is in progress. - **done:** The replay has finished. --- **NOTE:** This endpoint is available before the server has been marked ready and is updated in real time to facilitate monitoring the progress of the WAL replay. --- New in v2.28
-
readTargetMetadata
@Experimental List<MetricMetadata> readTargetMetadata(@Nullable @Nullable String matchTarget, @Nullable @Nullable String metric, @Nullable @Nullable Integer limit) Returns target metadataThe following endpoint returns metadata about metrics currently scraped from targets. This is experimental and might change in the future. The "data" section of the query result consists of a list of objects that contain metric metadata and the target label set.
- Parameter:
matchTarget- Label selectors that match targets by their label sets. All targets are selected if left empty. (optional)metric- A metric name to retrieve metadata for. All metric metadata is retrieved if left empty. (optional)limit- Maximum number of targets to match. (optional)
-
readTargets
Returns current target discovery.Both the active and dropped targets are part of the response by default. "labels" represents the label set after relabelling has occurred. "discoveredLabels" represent the unmodified labels retrieved during service discovery before relabelling has occurred.
- Parameter:
state- The "state" query parameter allows the caller to filter by active or dropped targets, (e.g., "state=active", "state=dropped", "state=any"). (optional)
-