Prometheus API (0.5.1)

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
[
  • {
    }
]

configs

Get Prometheus Configuration

Get Prometheus configuration in various formats depending on the Content-Type request header

Responses

Response samples

Content type
{
  • "global": {
    },
  • "scrape_configs": [
    ]
}

Update Prometheus Configuration

Update entire Prometheus configuration file

Request Body schema: application/json
object (Global)

The global configuration specifies parameters that are valid in all other configuration contexts. They also serve as defaults for other configuration sections.

object (RuntimeConfig)
rule_files
Array of strings (Rule Files)

Rule files specifies a list of globs. Rules and alerts are read from all matching files.

scrape_config_files
Array of strings (Scrape Config Files)

Scrape config files specifies a list of globs. Scrape configs are read from all matching files and appended to the list of scrape configs.

Array of objects (Scrape Configs)

A list of scrape configurations.

object (Alerting)

Alerting specifies settings related to the Alertmanager.

Array of objects (Remote Write)

Settings related to the remote write feature.

object (Remote Read)

Settings related to the remote read feature.

object (Storage)

Storage related settings that are runtime reloadable.

object (Tracing)

Configures exporting traces.

Responses

Request samples

Content type
application/json

Update entire Prometheus configuration file

{
  • "global": {
    },
  • "scrape_configs": [
    ]
}

Response samples

Content type
application/json
[
  • {
    }
]

Update Part Of Prometheus Configuration

Update specific part of Prometheus configuration file

Request Body schema: application/json
object (Global)

The global configuration specifies parameters that are valid in all other configuration contexts. They also serve as defaults for other configuration sections.

object (RuntimeConfig)
rule_files
Array of strings (Rule Files)

Rule files specifies a list of globs. Rules and alerts are read from all matching files.

scrape_config_files
Array of strings (Scrape Config Files)

Scrape config files specifies a list of globs. Scrape configs are read from all matching files and appended to the list of scrape configs.

Array of objects (Scrape Configs)

A list of scrape configurations.

object (Alerting)

Alerting specifies settings related to the Alertmanager.

Array of objects (Remote Write)

Settings related to the remote write feature.

object (Remote Read)

Settings related to the remote read feature.

object (Storage)

Storage related settings that are runtime reloadable.

object (Tracing)

Configures exporting traces.

Responses

Request samples

Content type
application/json

Update Alertmanager configuration settings

{
  • "alerting": {
    }
}

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
[
  • {
    }
]