Prometheus API (0.4.2)

Download OpenAPI specification:Download

This project enhances the native Prometheus HTTP API by providing additional features and addressing its limitations. Running as a sidecar alongside the Prometheus server enables users to extend the capabilities of the API.

metrics

Metrics

Endpoint that serves Prometheus metrics.

Responses

Response samples

Content type
application/json
null

rules

Create Rule

Creates a new rule with a randomly generated filename

Request Body schema: application/json
file
string (File)
Default: ""
data
object (Data)
Default: {}

Responses

Request samples

Content type
application/json
Example

Creates Prometheus recording rule with the name ExampleRecordingRule

{
  • "data": {
    }
}

Response samples

Content type
application/json
[
  • {
    }
]

Create Rule

Creates a new rule file with the provided filename

path Parameters
file
required
string (File)
query Parameters
recreate
string (Recreate)
Default: "false"
Request Body schema: application/json
file
string (File)
Default: ""
data
object (Data)
Default: {}

Responses

Request samples

Content type
application/json
Example

Creates Prometheus recording rule with the name ExampleRecordingRule

{
  • "data": {
    }
}

Response samples

Content type
application/json
[
  • {
    }
]

Delete Rule

Deletes a rule that matches to the provided parameter

path Parameters
file
required
any (File)

Responses

Response samples

Content type
application/json
[
  • {
    }
]

export

Export Data From Prometheus

Exports data from Prometheus based on the provided PromQL

query Parameters
format
string (Format)
Default: "csv"
Request Body schema: application/json
expr
required
string (Expr)
start
string (Start)
end
string (End)
step
string (Step)
timestamp_format
string (Timestamp Format)
Default: "unix"
replace_fields
object (Replace Fields)
Default: {}

Responses

Request samples

Content type
application/json
Example

Count of successful logins by users per hour in a day

{
  • "expr": "users_login_count{status='success'}",
  • "start": "2024-01-30T00:00:00Z",
  • "end": "2024-01-31T23:59:59Z",
  • "step": "1h"
}

Response samples

Content type
null

metrics-lifecycle-policies

Get Metrics Lifecycle Policy By Name

Returns metrics lifecycle policy that match the provided name parameter

path Parameters
name
required
string (Name)

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Delete Metrics Lifecycle Policy

Deletes specific metrics lifecycle policy

path Parameters
name
required
string (Name)

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Update Metrics Lifecycle Policy By Name

Updates specific metrics lifecycle policy

path Parameters
name
required
string (Name)
Request Body schema: application/json
pattern
string (Pattern)
keep_for
string (Keep For)
description
string (Description)

Responses

Request samples

Content type
application/json
Example

Updates keep_for setting only

{
  • "keep_for": "10d"
}

Response samples

Content type
application/json
[
  • {
    }
]

Get All Metrics Lifecycle Policies

Returns all metrics lifecycle policies

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Create Metrics Lifecycle Policy

Creates a new metrics lifecycle policy

Request Body schema: application/json
name
required
string (Name)
match
required
string (Match)
keep_for
required
string (Keep For)
description
string (Description)

Responses

Request samples

Content type
application/json

Time-series matching with regex will be kept for 7 days

{
  • "name": "Example Policy",
  • "match": "{__name__=~'go_.*'}",
  • "keep_for": "7d",
  • "description": "Time-series matching with regex will be kept for 7 days."
}

Response samples

Content type
application/json
[
  • {
    }
]

Trigger Metrics Lifecycle Policies

Force triggers all new metrics lifecycle policies

Responses

Response samples

Content type
application/json
[
  • {
    }
]

health

Get System Health

Returns a 200 status when the prometheus-api is able to connect to the Prometheus server

Responses

Response samples

Content type
application/json
[
  • {
    }
]