Liking cljdoc? Tell your friends :D

prometheus-api.client

Client library to the Prometheus HTTP API.

All methods take a connection conn as a first argument. It's just a simple map in the form:

{:url "<prometheus_base_url>"}

The :url field value must contain the base URL of the Prometheus instance. It is not expected to contain the "/api/v1" part.

E.g. to connect to a local Prometheus instance:

{:url "http://localhost:9090"}
Client library to the [Prometheus HTTP API](https://prometheus.io/docs/prometheus/latest/querying/api/).

All methods take a connection `conn` as a first argument. It's just a simple map in the form:
```clojure
{:url "<prometheus_base_url>"}
```
The :url field value must contain the base URL of the Prometheus instance. It is not expected to contain the "/api/v1" part.

E.g. to connect to a local Prometheus instance:
```clojure
{:url "http://localhost:9090"}
```
raw docstring

alertmanagersclj

(alertmanagers conn)

Get an overview of the current state of the Prometheus alertmanager discovery.

This corresponds to the /alertmanagers endpoint.

Get an overview of the current state of the Prometheus alertmanager discovery.

This corresponds to the [/alertmanagers endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#alertmanagers).
sourceraw docstring

alertsclj

(alerts conn)

Get the list of active alerts.

This corresponds to the /alerts endpoint.

Get the list of active alerts.

This corresponds to the [/alerts endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#alerts).
sourceraw docstring

api-prefixclj

Constant part in the API url. Can be overridden e.g. in case of passing through a reverse proxy.

Constant part in the API url.
Can be overridden e.g. in case of passing through a reverse proxy.
sourceraw docstring

build-informationclj

(build-information conn)

Get various build information about the instance.

This corresponds to the /status/buildinfo endpoint.

Get various build information about the instance.

This corresponds to the [/status/buildinfo endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#build-information).
sourceraw docstring

clean-tombstonesclj

(clean-tombstones conn)

creates a snapshot of all current data into snapshots/<datetime>-<rand> under the TSDB's data directory. The created directory is returned as a response.

If fails, returns an exception (Slingshot Stone to be precise) with :status 204.

This corresponds to the /admin/tsdb/clean_tombstones endpoint.

creates a snapshot of all current data into snapshots/<datetime>-<rand> under the TSDB's data directory.
The created directory is returned as a response.

If fails, returns an exception ([Slingshot](https://github.com/scgilardi/slingshot) Stone to be precise) with :status 204.

This corresponds to the [/admin/tsdb/clean_tombstones endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#clean-tombstones).
sourceraw docstring

configclj

(config conn)

Get the currently loaded configuration file.

This corresponds to the /status/config endpoint.

Get the currently loaded configuration file.

This corresponds to the [/status/config endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#config).
sourceraw docstring

content-levelclj

Level of content returned for API response calls. Valid values:

  • ::http-client: raw response from clj-http.client, good for debugging
  • ::body: HTTP body parsing into a clojure data structure
  • ::data: "data" part of the prometheus response
  • ::best: only the most sensible data for each endpoint (default)
Level of content returned for API response calls.
Valid values:
- `::http-client`: raw response from `clj-http.client`, good for debugging
- `::body`: HTTP body parsing into a clojure data structure
- `::data`: "data" part of the prometheus response
- `::best`: only the most sensible data for each endpoint (default)
sourceraw docstring

convert-resultclj

If true, parse convert the results into more clojuresque data structures. Time series are converted into maps, their timestamps converted into inst and scalar values parsed.

Default value is true.

Gets ignored if content-level is ::http-client

If true, parse convert the results into more clojuresque data structures.
Time series are converted into maps, their timestamps converted into inst and scalar values parsed.

Default value is true.

Gets ignored if [[content-level]] is `::http-client`
sourceraw docstring

delete-seriesclj

(delete-series conn series-matchers & {:keys [start end]})

Deletes data for a selection of series (matched by a list of series-matchers) in optional time range (bound from :start to :end).

If fails, returns an exception (Slingshot Stone to be precise) with :status 204.

The actual data will still exist on disk and will be cleaned up in future compactions. This can be forced by calling the clean-tombstones API endpoint.

This corresponds to the /admin/tsdb/delete_series endpoint.

Deletes data for a selection of series (matched by a list of `series-matchers`) in optional time range (bound from `:start` to `:end`).

If fails, returns an exception ([Slingshot](https://github.com/scgilardi/slingshot) Stone to be precise) with :status 204.

The actual data will still exist on disk and will be cleaned up in future compactions. This can be forced by calling the [[clean-tombstones]] API endpoint.

This corresponds to the [/admin/tsdb/delete_series endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#delete-series).
sourceraw docstring

flagsclj

(flags conn)

Get the instance configuration flags.

This corresponds to the /status/flags endpoint.

Get the instance configuration flags.

This corresponds to the [/status/flags endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#flags).
sourceraw docstring

labelsclj

(labels conn & {:keys [start end]})

Get the list of label names.

Optionally, we can filter on those present in a time range (with :start and :end).

This corresponds to the /labels endpoint.

Get the list of label names.

Optionally, we can filter on those present in a time range (with `:start` and `:end`).

This corresponds to the [/labels endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#getting-label-names).
sourceraw docstring

metadataclj

(metadata conn & {:keys [metric limit]})

Get metadata about metrics.

Same as targets-metadata except doesn't contextualize with target names.

Optionally, we can filter on a specific :metric. A :limit can also be optionally specified.

This corresponds to the /metadata endpoint.

Get metadata about metrics.

Same as [[targets-metadata]] except doesn't contextualize with target names.

Optionally, we can filter on a specific `:metric`.
A `:limit` can also be optionally specified.

This corresponds to the [/metadata endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#querying-metric-metadata).
sourceraw docstring

queryclj

(query conn q & {:keys [at timeout]})

Query data with q at an instant :at. When :at is omitted, last data point is returned. Optionally, a :timeout can be specified.

If you cant to query over a time range, use query-range.

This corresponds to the /query endpoint.

Query data with `q` at an instant `:at`.
When `:at` is omitted, last data point is returned.
Optionally, a `:timeout` can be specified.

If you cant to query over a time range, use [[query-range]].

This corresponds to the [/query endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#instant-queries).
sourceraw docstring

query-rangeclj

(query-range conn q start end step & {:keys [timeout]})

Query data with q over a time range (from start to end with step duration between points). Optionally, a :timeout can be specified.

If you cant to query only at a given instant, use query.

This corresponds to the /query_range endpoint.

Query data with `q` over a time range (from `start` to `end` with `step` duration between points).
Optionally, a `:timeout` can be specified.

If you cant to query only at a given instant, use [[query]].

This corresponds to the [/query_range endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#range-queries).
sourceraw docstring

rulesclj

(rules conn & {:keys [type]})

Get the list of alerting and / or recording rules.

Optionally, we can filter on the :type of rule. Valid values are: "alert" & "record"

This corresponds to the /rules endpoint.

Get the list of alerting and / or recording rules.

Optionally, we can filter on the `:type` of rule.
Valid values are: "alert" & "record"

This corresponds to the [/rules endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#rules).
sourceraw docstring

seriesclj

(series conn series-matchers & {:keys [start end]})

Query series according to list of series-matchers.

Optionally, we can filter on those present in a time range (with :start and :end).

This corresponds to the /series endpoint.

Query series according to list of `series-matchers`.

Optionally, we can filter on those present in a time range (with `:start` and `:end`).

This corresponds to the [/series endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#finding-series-by-label-matchers).
sourceraw docstring

snapshotclj

(snapshot conn & {:keys [skip-head]})

Creates a snapshot of all current data into snapshots/<datetime>-<rand> under the TSDB's data directory. The created directory is returned as a response.

Setting :skip_head to true allows skipping snapshotting data present only in the head block (not yet compacted on disk).

This corresponds to the /admin/tsdb/snapshot endpoint.

Creates a snapshot of all current data into snapshots/<datetime>-<rand> under the TSDB's data directory.
The created directory is returned as a response.

Setting `:skip_head` to true allows skipping snapshotting data present only in the head block (not yet compacted on disk).

This corresponds to the [/admin/tsdb/snapshot endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#snapshot).
sourceraw docstring

targetsclj

(targets conn & {:keys [state]})

Get the list of targets gathered through target discovery.

Optionally, we can filter on the :state of the targets. Valid values are: "active", "dropped" & "any" (same as when left empty)

This corresponds to the /targets endpoint.

Get the list of targets gathered through target discovery.

Optionally, we can filter on the `:state` of the targets.
Valid values are: "active", "dropped" & "any" (same as when left empty)

This corresponds to the [/targets endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#targets).
sourceraw docstring

targets-metadataclj

(targets-metadata conn & {:keys [label-matcher metric limit]})

Get metadata about metrics scrapped from targets.

Optionally, we can filter on a specific :metric and :label-matcher ("match_target" URL parameter). A :limit can also be optionally specified.

This corresponds to the /targets/metadata endpoint.

Get metadata about metrics scrapped from targets.

Optionally, we can filter on a specific `:metric` and `:label-matcher` ("match_target" URL parameter).
A `:limit` can also be optionally specified.

This corresponds to the [/targets/metadata endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#querying-target-metadata).
sourceraw docstring

tsdb-statsclj

(tsdb-stats conn)

Get various various stats about the cardinality of the TSDB.

This corresponds to the /status/tsdb endpoint.

Get various various stats about the cardinality of the TSDB.

This corresponds to the [/status/tsdb endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#tsdb-stats).
sourceraw docstring

values-for-labelclj

(values-for-label conn label & {:keys [start end]})

Get the list of values for a label name.

Optionally, we can filter on those present in a time range (with :start and :end).

This corresponds to the /label/<label_name>/values endpoint.

Get the list of values for a `label` name.

Optionally, we can filter on those present in a time range (with `:start` and `:end`).

This corresponds to the [/label/<label_name>/values endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#querying-label-values).
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close