KosmoKrator

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, configure, and verify
# 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.

KeyEnv varTypeRequiredLabel
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.

Generic CLI call
kosmo integrations:call prometheus.prometheus_list_alerts '{"filter":"example_filter","receiver":"example_receiver"}' --json
Provider shortcut
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.

Discovery commands
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 read
Parameters
filter, receiver
Generic call
kosmo integrations:call prometheus.prometheus_list_alerts '{"filter":"example_filter","receiver":"example_receiver"}' --json
Shortcut
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 read
Parameters
name
Generic call
kosmo integrations:call prometheus.prometheus_get_alert '{"name":"example_name"}' --json
Shortcut
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 read
Parameters
type
Generic call
kosmo integrations:call prometheus.prometheus_list_rules '{"type":"example_type"}' --json
Shortcut
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 read
Parameters
name
Generic call
kosmo integrations:call prometheus.prometheus_get_rule '{"name":"example_name"}' --json
Shortcut
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 read
Parameters
state
Generic call
kosmo integrations:call prometheus.prometheus_list_targets '{"state":"example_state"}' --json
Shortcut
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 read
Parameters
instance
Generic call
kosmo integrations:call prometheus.prometheus_get_target '{"instance":"example_instance"}' --json
Shortcut
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 read
Parameters
none
Generic call
kosmo integrations:call prometheus.prometheus_get_current_user '{}' --json
Shortcut
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
Schema command
kosmo integrations:schema prometheus.prometheus_list_alerts --json
ParameterTypeRequiredDescription
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
Schema command
kosmo integrations:schema prometheus.prometheus_get_alert --json
ParameterTypeRequiredDescription
name string yes The name of the alert to retrieve.
prometheus.prometheus_list_rules 1 parameters
Schema command
kosmo integrations:schema prometheus.prometheus_list_rules --json
ParameterTypeRequiredDescription
type string no Filter rules by type: "alert" for alerting rules or "recording" for recording rules.
prometheus.prometheus_get_rule 1 parameters
Schema command
kosmo integrations:schema prometheus.prometheus_get_rule --json
ParameterTypeRequiredDescription
name string yes The name of the rule group to retrieve.
prometheus.prometheus_list_targets 1 parameters
Schema command
kosmo integrations:schema prometheus.prometheus_list_targets --json
ParameterTypeRequiredDescription
state string no Filter targets by state: "active" or "dropped".
prometheus.prometheus_get_target 1 parameters
Schema command
kosmo integrations:schema prometheus.prometheus_get_target --json
ParameterTypeRequiredDescription
instance string yes The target instance address (e.g., "localhost:9090").
prometheus.prometheus_get_current_user 0 parameters
Schema command
kosmo integrations:schema prometheus.prometheus_get_current_user --json
ParameterTypeRequiredDescription
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.