analytics
Prometheus CLI for AI Agents
Use the Prometheus CLI from KosmoKrator to call Prometheus tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.Prometheus CLI Setup
Prometheus can be configured headlessly with `kosmokrator integrations:configure prometheus`.
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash
# Configure and verify this integration.
kosmokrator integrations:configure prometheus --set api_token="$PROMETHEUS_API_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor prometheus --json
kosmokrator integrations:status --json Credentials
Authentication type: API token api_token. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
api_token | PROMETHEUS_API_TOKEN | Secret secret | yes | API Token |
Command Patterns
The generic command is stable across every integration. The provider shortcut is shorter for humans.
kosmo integrations:call prometheus.prometheus_list_alerts '{"filter":"example_filter","receiver":"example_receiver"}' --json kosmo integrations:prometheus prometheus_list_alerts '{"filter":"example_filter","receiver":"example_receiver"}' --json Discovery
These commands return structured output for coding agents that need to inspect capabilities before choosing a function.
kosmo integrations:docs prometheus --json
kosmo integrations:docs prometheus.prometheus_list_alerts --json
kosmo integrations:schema prometheus.prometheus_list_alerts --json
kosmo integrations:search "Prometheus" --json
kosmo integrations:list --json Automation Contexts
The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.
CLI Functions
Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.
prometheus.prometheus_list_alerts
List Prometheus alerts. Optionally filter by alert state or label selectors. Returns alert names, states, labels, and annotations.
read - Parameters
- filter, receiver
kosmo integrations:call prometheus.prometheus_list_alerts '{"filter":"example_filter","receiver":"example_receiver"}' --json kosmo integrations:prometheus prometheus_list_alerts '{"filter":"example_filter","receiver":"example_receiver"}' --json prometheus.prometheus_get_alert
Get a Prometheus alert by name. Returns the full alert definition including labels, annotations, and state.
read - Parameters
- name
kosmo integrations:call prometheus.prometheus_get_alert '{"name":"example_name"}' --json kosmo integrations:prometheus prometheus_get_alert '{"name":"example_name"}' --json prometheus.prometheus_list_rules
List Prometheus alerting and recording rules. Optionally filter by type. Returns rule groups with their rules and states.
read - Parameters
- type
kosmo integrations:call prometheus.prometheus_list_rules '{"type":"example_type"}' --json kosmo integrations:prometheus prometheus_list_rules '{"type":"example_type"}' --json prometheus.prometheus_get_rule
Get a Prometheus rule group by name. Returns the full rule group definition including all rules within the group.
read - Parameters
- name
kosmo integrations:call prometheus.prometheus_get_rule '{"name":"example_name"}' --json kosmo integrations:prometheus prometheus_get_rule '{"name":"example_name"}' --json prometheus.prometheus_list_targets
List Prometheus scrape targets. Optionally filter by state (active or dropped). Returns target health status, labels, and scrape info.
read - Parameters
- state
kosmo integrations:call prometheus.prometheus_list_targets '{"state":"example_state"}' --json kosmo integrations:prometheus prometheus_list_targets '{"state":"example_state"}' --json prometheus.prometheus_get_target
Get a Prometheus target by its instance address. Returns target health, last scrape info, and discovery labels.
read - Parameters
- instance
kosmo integrations:call prometheus.prometheus_get_target '{"instance":"example_instance"}' --json kosmo integrations:prometheus prometheus_get_target '{"instance":"example_instance"}' --json prometheus.prometheus_get_current_user
Get the current authenticated Prometheus user info. Useful for verifying authentication and retrieving user details.
read - Parameters
- none
kosmo integrations:call prometheus.prometheus_get_current_user '{}' --json kosmo integrations:prometheus prometheus_get_current_user '{}' --json Function Schemas
Use these parameter tables when building CLI payloads without calling integrations:schema first.
prometheus.prometheus_list_alerts 2 parameters
kosmo integrations:schema prometheus.prometheus_list_alerts --json | Parameter | Type | Required | Description |
|---|---|---|---|
filter | string | no | Optional label selector filter (e.g., "severity=critical"). |
receiver | string | no | Filter alerts by receiver name. |
prometheus.prometheus_get_alert 1 parameters
kosmo integrations:schema prometheus.prometheus_get_alert --json | Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | The name of the alert to retrieve. |
prometheus.prometheus_list_rules 1 parameters
kosmo integrations:schema prometheus.prometheus_list_rules --json | Parameter | Type | Required | Description |
|---|---|---|---|
type | string | no | Filter rules by type: "alert" for alerting rules or "recording" for recording rules. |
prometheus.prometheus_get_rule 1 parameters
kosmo integrations:schema prometheus.prometheus_get_rule --json | Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | The name of the rule group to retrieve. |
prometheus.prometheus_list_targets 1 parameters
kosmo integrations:schema prometheus.prometheus_list_targets --json | Parameter | Type | Required | Description |
|---|---|---|---|
state | string | no | Filter targets by state: "active" or "dropped". |
prometheus.prometheus_get_target 1 parameters
kosmo integrations:schema prometheus.prometheus_get_target --json | Parameter | Type | Required | Description |
|---|---|---|---|
instance | string | yes | The target instance address (e.g., "localhost:9090"). |
prometheus.prometheus_get_current_user 0 parameters
kosmo integrations:schema prometheus.prometheus_get_current_user --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
Permissions
Headless calls still follow the integration read/write permission policy. Configure read/write defaults with
integrations:configure. Add --force only for trusted automation that should bypass that policy.