Skip to content

prometheus get-targets

Get the Prometheus target discovery

Description

Returns an overview of the current state of the Prometheus target discovery

Synopsis

prometheus get-targets
    [--site <site>]
    [--cluster <cluster>]
    [<state>]

Arguments

site - (string)

     Site where this command will be executed
     Example: --site "site-1"
     Default: input.site      Attributes: optional

cluster - (string)

     Name of prometheus cluster
     Example: --cluster "prometheus-default"
     Default: prometheus-default      Attributes: optional

state - (string)

     Used to filter targets (either active or dropped). Possible values are active, dropped, any
     Example: "active"
     Default: _None_      Attributes: optional

Examples

Input:

! prometheus get-targets "active"
Output:
{
  "status": "success",
  "data": {
    "activeTargets": [
      {
        "discoveredLabels": {
          "__address__": "localhost:1234",
          "__metrics_path__": "/metrics",
          "__scheme__": "http",
          "job": "kafka"
        },
        "labels": {
          "instance": "localhost:1234",
          "job": "kafka"
        },
        "scrapePool": "kafka",
        "scrapeUrl": "http://localhost:1234/metrics",
        "globalUrl": "http://beehyv-H81M-S:1234/metrics",
        "lastError": "Get \"http://localhost:1234/metrics\": dial tcp 127.0.0.1:1234: connect: connection refused",
        "lastScrape": "2021-10-21T08:02:32.877553278+05:30",
        "lastScrapeDuration": 0.000657934,
        "health": "down"
      },
      {
        "discoveredLabels": {
          "__address__": "localhost:9100",
          "__metrics_path__": "/metrics",
          "__scheme__": "http",
          "job": "node-exporter"
        },
        "labels": {
          "instance": "localhost:9100",
          "job": "node-exporter"
        },
        "scrapePool": "node-exporter",
        "scrapeUrl": "http://localhost:9100/metrics",
        "globalUrl": "http://beehyv-H81M-S:9100/metrics",
        "lastError": "Get \"http://localhost:9100/metrics\": dial tcp 127.0.0.1:9100: connect: connection refused",
        "lastScrape": "2021-10-21T08:02:30.284777044+05:30",
        "lastScrapeDuration": 0.000598593,
        "health": "down"
      },
      {
        "discoveredLabels": {
          "__address__": "localhost:9090",
          "__metrics_path__": "/metrics",
          "__scheme__": "http",
          "job": "prometheus"
        },
        "labels": {
          "instance": "localhost:9090",
          "job": "prometheus"
        },
        "scrapePool": "prometheus",
        "scrapeUrl": "http://localhost:9090/metrics",
        "globalUrl": "http://beehyv-H81M-S:9090/metrics",
        "lastError": "",
        "lastScrape": "2021-10-21T08:02:39.829747752+05:30",
        "lastScrapeDuration": 0.009807423,
        "health": "up"
      }
    ],
    "droppedTargets": []
  }
}

Access Control

To use this command, you need access to the following:

Field Value
Action "read"
Service Type "prometheus"
Service Instance cluster
Namespace
Object Type
Object ID

Please see Access Control for details.