Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboards): [experiment] Building Grafana Dashboards from Loki #14411

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

owen-d
Copy link
Member

@owen-d owen-d commented Oct 7, 2024

[WIP] Generate grafana compatible dashboard spec from within loki itself, hosted on /grafana/dashboards/{dashboard} endpoints

  • fully functional
  • Consumes prometheus' client_golang to extract metrics from within source code and generates dashboards from them.
  • dashboards generated from code + some RED method helpers
  • generates dashboard spec from foundation sdk
  • compiler guarantees we generate correct specifications
  • coupling with loki source code itself for no-nonsense upgrading (refactor metric names and have dashboards update accordingly)
  • couple source code, operational expertise, and metrics together for compatibility

Example of generated output

{
  "title": "Loki Reads (generated)",
  "tags": [
    "generated",
    "from",
    "go"
  ],
  "timezone": "utc",
  "editable": true,
  "graphTooltip": 0,
  "time": {
    "from": "now-30m",
    "to": "now"
  },
  "fiscalYearStartMonth": 0,
  "refresh": "1m",
  "schemaVersion": 39,
  "panels": [
    {
      "type": "row",
      "collapsed": false,
      "title": "Distributor",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 0,
      "panels": [
        {
          "type": "timeseries",
          "targets": [
            {
              "expr": "\n\tsum(\n\t\trate(\n\t\t\t\"loki_request_duration_seconds\"_sum{ namespace=~\".*loki.*\" }\n\t\t\t[$__rate_interval]\n\t\t)\n\t) by (container=\"distributor\")\n\t/\n\tsum(\n\t\trate(\n\t\t\t\"loki_request_duration_seconds\"_count{ namespace=~\".*loki.*\" }\n\t\t\t[$__rate_interval]\n\t\t)\n\t) by (container=\"distributor\")\n\t",
              "legendFormat": "{{ container=\"distributor\" }}",
              "refId": ""
            }
          ],
          "title": "qps",
          "transparent": false,
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 0,
            "y": 1
          },
          "options": {
            "legend": {
              "displayMode": "list",
              "placement": "bottom",
              "showLegend": false,
              "calcs": []
            },
            "tooltip": {
              "mode": "",
              "sort": ""
            }
          },
          "fieldConfig": {
            "defaults": {
              "unit": "seconds",
              "min": 0
            },
            "overrides": null
          }
        },
        {
          "type": "timeseries",
          "targets": [
            {
              "expr": "\n\thistogram_quantile(\n\t  0.50,90,99,\n\t\tsum(\n\t\t\trate(\n\t\t\t  \"loki_request_duration_seconds\"_bucket{ namespace=~\".*loki.*\" }\n\t\t\t\t[$__rate_interval]\n\t\t\t)\n\t\t) by (container=\"distributor\", le)\n\t)\n\t",
              "legendFormat": "{{ container=\"distributor\", p50,90,99 }}",
              "refId": ""
            }
          ],
          "title": "latency",
          "transparent": false,
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 12,
            "y": 1
          },
          "options": {
            "legend": {
              "displayMode": "list",
              "placement": "bottom",
              "showLegend": false,
              "calcs": []
            },
            "tooltip": {
              "mode": "",
              "sort": ""
            }
          },
          "fieldConfig": {
            "defaults": {
              "unit": "seconds",
              "min": 0
            },
            "overrides": null
          }
        },
        {
          "type": "timeseries",
          "targets": [
            {
              "expr": "\n\thistogram_quantile(\n\t  0.50,90,99,\n\t\tsum(\n\t\t\trate(\n\t\t\t  \"loki_request_duration_seconds\"_bucket{ namespace=~\".*loki.*\" }\n\t\t\t\t[$__rate_interval]\n\t\t\t)\n\t\t) by (container=\"distributor\", pod, le)\n\t)\n\t",
              "legendFormat": "{{ container=\"distributor\", pod, p50,90,99 }}",
              "refId": ""
            }
          ],
          "title": "latency",
          "transparent": false,
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 0,
            "y": 10
          },
          "options": {
            "legend": {
              "displayMode": "list",
              "placement": "bottom",
              "showLegend": false,
              "calcs": []
            },
            "tooltip": {
              "mode": "",
              "sort": ""
            }
          },
          "fieldConfig": {
            "defaults": {
              "unit": "seconds",
              "min": 0
            },
            "overrides": null
          }
        }
      ]
    },
    {
      "type": "row",
      "collapsed": false,
      "title": "Ingester",
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 19
      },
      "id": 0,
      "panels": [
        {
          "type": "timeseries",
          "targets": [
            {
              "expr": "\n\tsum(\n\t\trate(\n\t\t\t\"loki_request_duration_seconds\"_sum{ namespace=~\".*loki.*\" }\n\t\t\t[$__rate_interval]\n\t\t)\n\t) by (container=\"ingester\")\n\t/\n\tsum(\n\t\trate(\n\t\t\t\"loki_request_duration_seconds\"_count{ namespace=~\".*loki.*\" }\n\t\t\t[$__rate_interval]\n\t\t)\n\t) by (container=\"ingester\")\n\t",
              "legendFormat": "{{ container=\"ingester\" }}",
              "refId": ""
            }
          ],
          "title": "qps",
          "transparent": false,
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 0,
            "y": 20
          },
          "options": {
            "legend": {
              "displayMode": "list",
              "placement": "bottom",
              "showLegend": false,
              "calcs": []
            },
            "tooltip": {
              "mode": "",
              "sort": ""
            }
          },
          "fieldConfig": {
            "defaults": {
              "unit": "seconds",
              "min": 0
            },
            "overrides": null
          }
        },
        {
          "type": "timeseries",
          "targets": [
            {
              "expr": "\n\thistogram_quantile(\n\t  0.50,90,99,\n\t\tsum(\n\t\t\trate(\n\t\t\t  \"loki_request_duration_seconds\"_bucket{ namespace=~\".*loki.*\" }\n\t\t\t\t[$__rate_interval]\n\t\t\t)\n\t\t) by (container=\"ingester\", le)\n\t)\n\t",
              "legendFormat": "{{ container=\"ingester\", p50,90,99 }}",
              "refId": ""
            }
          ],
          "title": "latency",
          "transparent": false,
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 12,
            "y": 20
          },
          "options": {
            "legend": {
              "displayMode": "list",
              "placement": "bottom",
              "showLegend": false,
              "calcs": []
            },
            "tooltip": {
              "mode": "",
              "sort": ""
            }
          },
          "fieldConfig": {
            "defaults": {
              "unit": "seconds",
              "min": 0
            },
            "overrides": null
          }
        },
        {
          "type": "timeseries",
          "targets": [
            {
              "expr": "\n\thistogram_quantile(\n\t  0.50,90,99,\n\t\tsum(\n\t\t\trate(\n\t\t\t  \"loki_request_duration_seconds\"_bucket{ namespace=~\".*loki.*\" }\n\t\t\t\t[$__rate_interval]\n\t\t\t)\n\t\t) by (container=\"ingester\", pod, le)\n\t)\n\t",
              "legendFormat": "{{ container=\"ingester\", pod, p50,90,99 }}",
              "refId": ""
            }
          ],
          "title": "latency",
          "transparent": false,
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 0,
            "y": 29
          },
          "options": {
            "legend": {
              "displayMode": "list",
              "placement": "bottom",
              "showLegend": false,
              "calcs": []
            },
            "tooltip": {
              "mode": "",
              "sort": ""
            }
          },
          "fieldConfig": {
            "defaults": {
              "unit": "seconds",
              "min": 0
            },
            "overrides": null
          }
        }
      ]
    }
  ],
  "templating": {},
  "annotations": {}
}

Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
@owen-d owen-d changed the title [experiment] Building Grafana Dashboards from Loki feat(dashboards): [experiment] Building Grafana Dashboards from Loki Oct 7, 2024
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
@pull-request-size pull-request-size bot added size/XL and removed size/L labels Oct 9, 2024
owen-d and others added 12 commits October 9, 2024 14:57
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
Signed-off-by: Owen Diehl <[email protected]>
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ owen-d
❌ K-Phoen
You have signed the CLA already but the status is still pending? Let us recheck it.

Signed-off-by: Owen Diehl <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants