Some sample code around prometheus
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Nicolas Massé b23aa5fb0f initial commit 3 years ago
.podman-compose/prometheus initial commit 3 years ago
README.md initial commit 3 years ago
go.mod initial commit 3 years ago
go.sum initial commit 3 years ago
main.go initial commit 3 years ago
podman-compose.yaml initial commit 3 years ago

README.md

Discovering Prometheus

Installation

podman-compose up -d
go run main.go scrape

Usage

$ curl -s -X POST http://localhost:9090/api/v1/query_range -d query='myapp_processed_ops_total' --data-urlencode start="$(date -Iseconds -u --date='1 minute ago')" --data-urlencode end="$(date -Iseconds -u)" -d step=5s | jq .

{
  "status": "success",
  "data": {
    "resultType": "matrix",
    "result": [
      {
        "metric": {
          "__name__": "myapp_processed_ops_total",
          "instance": "192.168.122.1:2112",
          "job": "test-exporter"
        },
        "values": [
          [
            1656171931,
            "359"
          ],
          [
            1656171936,
            "361"
          ],
          [
            1656171941,
            "364"
          ],
          [
            1656171946,
            "367"
          ],
          [
            1656171951,
            "369"
          ],
          [
            1656171956,
            "371"
          ],
          [
            1656171961,
            "374"
          ],
          [
            1656171966,
            "376"
          ],
          [
            1656171971,
            "379"
          ],
          [
            1656171976,
            "381"
          ],
          [
            1656171981,
            "384"
          ],
          [
            1656171986,
            "386"
          ],
          [
            1656171991,
            "389"
          ]
        ]
      }
    ]
  }
}