Grafana

From bibbleWiki
Revision as of 03:17, 18 July 2025 by Iwiseman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

This is a quick page to note about setup of Grafana

CA Cert

The CA Cert is configured against the datasource. You cut and paste the rootCA.pem. Otherwise you get the error

client: failed to call resources: error querying resource: Post \"https://192.168.1.220:9090/api/v1/labels\": tls: failed to verify certificate: x509: certificate signed by unknown authority

Data Frames

Gosh it is all lingo. This is what grafana refers to for it internal layout.

{
  "status": "success",
  "data": {
    "resultType": "matrix",
    "result": [
      {
        "metric": {
          "__name__": "caddy_requests_by_5min",
          "bucket": "1752712500",
          "instance": "192.168.1.220:8080",
          "job": "bibble-caddy-exporter",
          "site": "wiki.bibble.co.nz"
        },
        "values": [
          [
            1752719700,
            "123"
          ]
        ]
      },
      {
        "metric": {
          "__name__": "caddy_requests_by_5min",
          "bucket": "1752712800",
          "instance": "192.168.1.220:8080",
          "job": "bibble-caddy-exporter",
          "site": "wiki.bibble.co.nz"
        },
        "values": [
          [
            1752719700,
            "118"
          ]
        ]
      },
    ]
  }
}

View a data frame this would look like this. Note it is the prometheus generated timestamp in the value which makes these data frames. Here they are not unique because the scrape time was the same.

Time (Scrape TS) Value Bucket Label Site Instance Job Frame Explanation
1752719700 123 1752712500 wiki.bibble.co.nz 192.168.1.220:8080 bibble-caddy-exporter Not Unique as Scrap time the same
1752719700 118 1752712800 wiki.bibble.co.nz 192.168.1.220:8080 bibble-caddy-exporter Not Unique as Scrap time the same)

This matters a you cannot use organize fields in transformations

Getting My Graph to Work

So to get this to work using the data above I used Labels to Fields which gives

Site Bucket Timestamp Value
wiki.bibble.co.nz 1752712500 1752719700 123
wiki.bibble.co.nz 1752712800 1752719700 118

Then merge which gives

Time Site Bucket Requests
1752719700 wiki.bibble.co.nz 1752712500 123
1752719700 wiki.bibble.co.nz 1752712800 118

Than Add field from Calculation with row index

Row Index Time Site Bucket Requests
0 1752719700 wiki.bibble.co.nz 1752712500 123
1 1752719700 wiki.bibble.co.nz 1752712800 118

From there you can make the index a string to use as the label and you get this