From 136275cfc067cc713746556c04933a32d5608d97 Mon Sep 17 00:00:00 2001 From: John Harris Date: Tue, 28 Jul 2020 01:36:37 -0700 Subject: [PATCH] dashboards/.*.json to jinja2 (#47) Main intent was to extend the JSON dashboards to support more dynamic "job" names and to be able to switch out "instance" dashboard legends with "pod" keys. After this update most of the dashboards under dashboards/ are Jinja2 templates and the generate_dashboard.sh script now supports checking for and prompting if missing input/env vars which also resolves issue #45 Visual verification of post rendered templates was done. --- .../{bookkeeper.json => bookkeeper.json.j2} | 151 ++++++++++-------- dashboards/{jvm.json => jvm.json.j2} | 27 ++-- .../{messaging.json => messaging.json.j2} | 96 +++++------ dashboards/{node.json => node.json.j2} | 14 +- .../{overview.json => overview.json.j2} | 52 +++--- dashboards/{proxy.json => proxy.json.j2} | 67 ++++---- dashboards/{topic.json => topic.json.j2} | 16 +- .../{zookeeper.json => zookeeper.json.j2} | 67 ++++---- scripts/generate_dashboards.sh | 114 +++++++++---- 9 files changed, 350 insertions(+), 254 deletions(-) rename dashboards/{bookkeeper.json => bookkeeper.json.j2} (92%) rename dashboards/{jvm.json => jvm.json.j2} (91%) rename dashboards/{messaging.json => messaging.json.j2} (94%) rename dashboards/{node.json => node.json.j2} (99%) rename dashboards/{overview.json => overview.json.j2} (95%) rename dashboards/{proxy.json => proxy.json.j2} (87%) rename dashboards/{topic.json => topic.json.j2} (98%) rename dashboards/{zookeeper.json => zookeeper.json.j2} (93%) diff --git a/dashboards/bookkeeper.json b/dashboards/bookkeeper.json.j2 similarity index 92% rename from dashboards/bookkeeper.json rename to dashboards/bookkeeper.json.j2 index 1dd9691..bb77044 100644 --- a/dashboards/bookkeeper.json +++ b/dashboards/bookkeeper.json.j2 @@ -1,3 +1,12 @@ +{%- if PULSAR_CUSTOM_PROMETHEUS not in [ '','no','No','NO','na','NA','false','False','0' ] %} +{#- +If custom change "instance" key to "pod" +This will make graph ledgends display the pod name instead of IP and port information +#} + {%- set CONTEXT = "pod" %} +{%- else %} + {%- set CONTEXT = "instance" %} +{%- endif -%} { "__inputs": [ { @@ -211,7 +220,7 @@ "tableColumn": "", "targets": [ { - "expr": "count(bookie_SERVER_STATUS{job=~\"$job\", instance=~\"$instance\"} == 0)\n", + "expr": "count(bookie_SERVER_STATUS{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"} == 0)\n", "format": "time_series", "intervalFactor": 1, "refId": "A" @@ -269,7 +278,7 @@ "steppedLine": false, "targets": [ { - "expr": "100 * sum(irate(bookkeeper_server_ADD_ENTRY_count{job=~\"$job\", instance=~\"$instance\", success=\"true\"}[30s])) / sum(irate(bookkeeper_server_ADD_ENTRY_count{job=~\"$job\", instance=~\"$instance\"}[30s]))", + "expr": "100 * sum(irate(bookkeeper_server_ADD_ENTRY_count{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\"}[30s])) / sum(irate(bookkeeper_server_ADD_ENTRY_count{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"}[30s]))", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -278,7 +287,7 @@ "step": 2 }, { - "expr": "100 * sum(irate(bookkeeper_server_READ_ENTRY_count{job=~\"$job\", instance=~\"$instance\", success=\"true\"}[30s])) / sum(irate(bookkeeper_server_READ_ENTRY_count{job=~\"$job\", instance=~\"$instance\"}[30s]))", + "expr": "100 * sum(irate(bookkeeper_server_READ_ENTRY_count{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\"}[30s])) / sum(irate(bookkeeper_server_READ_ENTRY_count{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"}[30s]))", "format": "time_series", "intervalFactor": 1, "legendFormat": "read_entry", @@ -363,7 +372,7 @@ "steppedLine": false, "targets": [ { - "expr": "avg(bookkeeper_server_ADD_ENTRY_REQUEST{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.99\"})", + "expr": "avg(bookkeeper_server_ADD_ENTRY_REQUEST{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.99\"})", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -372,35 +381,35 @@ "step": 2 }, { - "expr": "avg(bookkeeper_server_ADD_ENTRY_REQUEST{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.999\"})", + "expr": "avg(bookkeeper_server_ADD_ENTRY_REQUEST{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.999\"})", "format": "time_series", "intervalFactor": 1, "legendFormat": "add (p999)", "refId": "B" }, { - "expr": "avg(bookkeeper_server_ADD_ENTRY_REQUEST{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.5\"})", + "expr": "avg(bookkeeper_server_ADD_ENTRY_REQUEST{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.5\"})", "format": "time_series", "intervalFactor": 1, "legendFormat": "add (p50)", "refId": "C" }, { - "expr": "avg(bookkeeper_server_READ_ENTRY_REQUEST{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.99\"})", + "expr": "avg(bookkeeper_server_READ_ENTRY_REQUEST{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.99\"})", "format": "time_series", "intervalFactor": 1, "legendFormat": "read (p99)", "refId": "D" }, { - "expr": "avg(bookkeeper_server_READ_ENTRY_REQUEST{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.999\"})", + "expr": "avg(bookkeeper_server_READ_ENTRY_REQUEST{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.999\"})", "format": "time_series", "intervalFactor": 1, "legendFormat": "read (p999)", "refId": "E" }, { - "expr": "avg(bookkeeper_server_READ_ENTRY_REQUEST{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.5\"})", + "expr": "avg(bookkeeper_server_READ_ENTRY_REQUEST{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.5\"})", "format": "time_series", "intervalFactor": 1, "legendFormat": "read (p50)", @@ -508,7 +517,7 @@ "tableColumn": "", "targets": [ { - "expr": "100 \n* \ncount(bookie_SERVER_STATUS{job=~\"$job\", instance=~\"$instance\"} == 1)\n/\ncount(bookie_SERVER_STATUS{job=~\"$job\", instance=~\"$instance\"})\n ", + "expr": "100 \n* \ncount(bookie_SERVER_STATUS{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"} == 1)\n/\ncount(bookie_SERVER_STATUS{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"})\n ", "format": "time_series", "intervalFactor": 1, "refId": "A" @@ -659,7 +668,7 @@ "steppedLine": false, "targets": [ { - "expr": "sum(irate(bookkeeper_server_READ_ENTRY_count{job=~\"$job\", instance=~\"$instance\", success=\"true\"}[30s]))", + "expr": "sum(irate(bookkeeper_server_READ_ENTRY_count{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\"}[30s]))", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -668,7 +677,7 @@ "step": 2 }, { - "expr": "sum(irate(bookkeeper_server_ADD_ENTRY_count{job=~\"$job\", instance=~\"$instance\", success=\"true\"}[30s]))", + "expr": "sum(irate(bookkeeper_server_ADD_ENTRY_count{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\"}[30s]))", "format": "time_series", "intervalFactor": 1, "legendFormat": "add entry", @@ -763,11 +772,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(irate(bookie_WRITE_BYTES{job=~\"$job\", instance=~\"$instance\"}[30s])) by (instance)", + "expr": "sum(irate(bookie_WRITE_BYTES{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"}[30s])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -850,11 +859,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(irate(bookie_READ_BYTES{job=~\"$job\", instance=~\"$instance\"}[30s])) by (instance)", + "expr": "sum(irate(bookie_READ_BYTES{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"}[30s])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -937,11 +946,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(irate(bookkeeper_server_ADD_ENTRY_REQUEST_count{job=~\"$job\", instance=~\"$instance\"}[30s])) by (instance)", + "expr": "sum(irate(bookkeeper_server_ADD_ENTRY_REQUEST_count{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"}[30s])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -1024,11 +1033,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(irate(bookkeeper_server_READ_ENTRY_REQUEST_count{job=~\"$job\", instance=~\"$instance\"}[30s])) by (instance)", + "expr": "sum(irate(bookkeeper_server_READ_ENTRY_REQUEST_count{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"}[30s])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -1111,11 +1120,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookkeeper_server_ADD_ENTRY_REQUEST{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.5\"}) by (instance)", + "expr": "sum(bookkeeper_server_ADD_ENTRY_REQUEST{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.5\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -1198,11 +1207,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookkeeper_server_ADD_ENTRY_REQUEST{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.99\"}) by (instance)", + "expr": "sum(bookkeeper_server_ADD_ENTRY_REQUEST{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.99\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -1285,11 +1294,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookkeeper_server_ADD_ENTRY_REQUEST{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.999\"}) by (instance)", + "expr": "sum(bookkeeper_server_ADD_ENTRY_REQUEST{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.999\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -1372,11 +1381,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookkeeper_server_READ_ENTRY_REQUEST{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.5\"}) by (instance)", + "expr": "sum(bookkeeper_server_READ_ENTRY_REQUEST{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.5\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -1459,11 +1468,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookkeeper_server_READ_ENTRY_REQUEST{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.99\"}) by (instance)", + "expr": "sum(bookkeeper_server_READ_ENTRY_REQUEST{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.99\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -1546,11 +1555,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookkeeper_server_READ_ENTRY_REQUEST{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.999\"}) by (instance)", + "expr": "sum(bookkeeper_server_READ_ENTRY_REQUEST{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.999\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -1647,11 +1656,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(irate(bookie_journal_JOURNAL_SYNC_count{job=~\"$job\", instance=~\"$instance\", success=\"true\"}[30s])) by (instance)", + "expr": "sum(irate(bookie_journal_JOURNAL_SYNC_count{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\"}[30s])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 4 } @@ -1734,11 +1743,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(irate(bookie_journal_JOURNAL_ADD_ENTRY_count{job=~\"$job\", instance=~\"$instance\", success=\"true\"}[30s])) by (instance)", + "expr": "sum(irate(bookie_journal_JOURNAL_ADD_ENTRY_count{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\"}[30s])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 4 } @@ -1821,11 +1830,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_journal_JOURNAL_QUEUE_SIZE{job=~\"$job\", instance=~\"$instance\"}) by (instance)", + "expr": "sum(bookie_journal_JOURNAL_QUEUE_SIZE{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -1908,11 +1917,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_journal_JOURNAL_FORCE_WRITE_QUEUE_SIZE{job=~\"$job\", instance=~\"$instance\"}) by (instance)", + "expr": "sum(bookie_journal_JOURNAL_FORCE_WRITE_QUEUE_SIZE{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -1995,11 +2004,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_journal_JOURNAL_CB_QUEUE_SIZE{job=~\"$job\", instance=~\"$instance\"}) by (instance)", + "expr": "sum(bookie_journal_JOURNAL_CB_QUEUE_SIZE{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -2082,11 +2091,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_journal_JOURNAL_ADD_ENTRY{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.5\"}) by (instance)", + "expr": "sum(bookie_journal_JOURNAL_ADD_ENTRY{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.5\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -2169,11 +2178,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_journal_JOURNAL_ADD_ENTRY{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.99\"}) by (instance)", + "expr": "sum(bookie_journal_JOURNAL_ADD_ENTRY{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.99\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -2256,11 +2265,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_journal_JOURNAL_ADD_ENTRY{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"1.0\"}) by (instance)", + "expr": "sum(bookie_journal_JOURNAL_ADD_ENTRY{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"1.0\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -2343,11 +2352,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_journal_JOURNAL_SYNC{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.5\"}) by (instance)", + "expr": "sum(bookie_journal_JOURNAL_SYNC{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.5\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 4 } @@ -2430,11 +2439,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_journal_JOURNAL_SYNC{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"0.99\"}) by (instance)", + "expr": "sum(bookie_journal_JOURNAL_SYNC{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"0.99\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 4 } @@ -2517,11 +2526,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_journal_JOURNAL_SYNC{job=~\"$job\", instance=~\"$instance\", success=\"true\", quantile=\"1.0\"}) by (instance)", + "expr": "sum(bookie_journal_JOURNAL_SYNC{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\", success=\"true\", quantile=\"1.0\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 4 } @@ -2618,11 +2627,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_ledgers_count{job=~\"$job\", instance=~\"$instance\"}) by (instance)", + "expr": "sum(bookie_ledgers_count{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -2705,11 +2714,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_entries_count{job=~\"$job\", instance=~\"$instance\"}) by (instance)", + "expr": "sum(bookie_entries_count{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -2792,11 +2801,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_write_cache_size{job=~\"$job\", instance=~\"$$instance\"}) by (instance)", + "expr": "sum(bookie_write_cache_size{job=~\"$job\", {{ CONTEXT }}=~\"$${{ CONTEXT }}\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -2879,11 +2888,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_read_cache_size{job=~\"$job\", instance=~\"$instance\"}) by (instance)", + "expr": "sum(bookie_read_cache_size{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -2965,10 +2974,10 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_DELETED_LEDGER_COUNT{job=~\"$job\", instance=~\"$$instance\"}) by (instance)", + "expr": "sum(bookie_DELETED_LEDGER_COUNT{job=~\"$job\", {{ CONTEXT }}=~\"$${{ CONTEXT }}\"}) by ({{ CONTEXT }})", "format": "time_series", "intervalFactor": 1, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A" } ], @@ -3049,10 +3058,10 @@ "steppedLine": false, "targets": [ { - "expr": "sum(bookie_ledger_writable_dirs{job=~\"$job\", instance=~\"$$instance\"}) by (instance)", + "expr": "sum(bookie_ledger_writable_dirs{job=~\"$job\", {{ CONTEXT }}=~\"${{ CONTEXT }}\"}) by ({{ CONTEXT }})", "format": "time_series", "intervalFactor": 1, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A" } ], @@ -3120,9 +3129,9 @@ "multi": false, "name": "job", "options": [], - "query": "{job=~\".+\"}", + "query": "bookie_SERVER_STATUS{job=~\".+\"}", "refresh": 2, - "regex": "/.*[^_]job=\\\"(bookie)\\\".*/", + "regex": "/.*[^_]job=~\"(.*bookie)\".*/", "skipUrlSync": false, "sort": 1, "tagValuesQuery": "", @@ -3139,11 +3148,11 @@ "includeAll": true, "label": "Bookie", "multi": true, - "name": "instance", + "name": "{{ CONTEXT }}", "options": [], - "query": "bookkeeper_server_ADD_ENTRY{job=~\"$job\", instance=~\".+\"}", + "query": "bookkeeper_server_ADD_ENTRY{job=~\"$job\", {{ CONTEXT }}=~\".+\"}", "refresh": 2, - "regex": "/.*[^_]instance=\\\"([^\\\"]+)\\\".*/", + "regex": "/.*[^_]{{ CONTEXT }}=\"([^\"]+)\".*/", "skipUrlSync": false, "sort": 1, "tagValuesQuery": "", diff --git a/dashboards/jvm.json b/dashboards/jvm.json.j2 similarity index 91% rename from dashboards/jvm.json rename to dashboards/jvm.json.j2 index f10e148..1686e00 100644 --- a/dashboards/jvm.json +++ b/dashboards/jvm.json.j2 @@ -1,3 +1,12 @@ +{%- if PULSAR_CUSTOM_PROMETHEUS not in [ '','no','No','NO','na','NA','false','False','0' ] %} +{#- +If custom change "instance" key to "pod" +This will make graph ledgends display the pod name instead of IP and port information +#} + {%- set CONTEXT = "pod" %} +{%- else %} + {%- set CONTEXT = "instance" %} +{%- endif -%} { "__inputs": [ { @@ -102,11 +111,11 @@ "steppedLine": false, "targets": [ { - "expr": "irate(process_cpu_seconds_total{instance=~\"$instance\"}[30s]) * 100\n\n", + "expr": "irate(process_cpu_seconds_total{{ '{' }}{{ CONTEXT }}=~\"$instance\"}[30s]) * 100\n\n", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "metric": "process_cpu_seconds_total", "refId": "A", "step": 20 @@ -200,7 +209,7 @@ "steppedLine": false, "targets": [ { - "expr": "sum(jvm_memory_bytes_committed{instance=~\"$instance\"})", + "expr": "sum(jvm_memory_bytes_committed{{ '{' }}{{ CONTEXT }}=~\"$instance\"})", "format": "time_series", "hide": false, "interval": "", @@ -211,7 +220,7 @@ "step": 20 }, { - "expr": "sum(jvm_memory_bytes_used{instance=~\"$instance\"})", + "expr": "sum(jvm_memory_bytes_used{{ '{' }}{{ CONTEXT }}=~\"$instance\"})", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -221,7 +230,7 @@ "step": 20 }, { - "expr": "sum(jvm_memory_bytes_max{instance=~\"$instance\"})", + "expr": "sum(jvm_memory_bytes_max{{ '{' }}{{ CONTEXT }}=~\"$instance\"})", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -308,7 +317,7 @@ "steppedLine": false, "targets": [ { - "expr": "jvm_memory_direct_bytes_used{instance=~\"$instance\"}", + "expr": "jvm_memory_direct_bytes_used{{ '{' }}{{ CONTEXT }}=~\"$instance\"}", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -318,7 +327,7 @@ "step": 20 }, { - "expr": "jvm_memory_direct_bytes_max{instance=~\"$instance\"}", + "expr": "jvm_memory_direct_bytes_max{{ '{' }}{{ CONTEXT }}=~\"$instance\"}", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -414,7 +423,7 @@ "steppedLine": false, "targets": [ { - "expr": "sum(increase(jvm_gc_collection_seconds_sum{instance=~\"$instance\"}[30s]))", + "expr": "sum(increase(jvm_gc_collection_seconds_sum{{ '{' }}{{ CONTEXT }}=~\"$instance\"}[30s]))", "format": "time_series", "hide": false, "interval": "", @@ -526,7 +535,7 @@ "multi": true, "name": "instance", "options": [], - "query": "jvm_memory_bytes_used{job=~\"$job\", instance=~\".+\"}", + "query": "jvm_memory_bytes_used{job=~\"$job\", {{ CONTEXT }}=~\".+\"}", "refresh": 2, "regex": "/.*[^_]instance=\\\"([^\\\"]+)\\\".*/", "skipUrlSync": false, diff --git a/dashboards/messaging.json b/dashboards/messaging.json.j2 similarity index 94% rename from dashboards/messaging.json rename to dashboards/messaging.json.j2 index 25d5023..1614e08 100644 --- a/dashboards/messaging.json +++ b/dashboards/messaging.json.j2 @@ -130,7 +130,7 @@ "tableColumn": "", "targets": [ { - "expr": "sum(pulsar_topics_count{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_topics_count{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "intervalFactor": 1, "refId": "A" @@ -210,7 +210,7 @@ "tableColumn": "", "targets": [ { - "expr": "sum(pulsar_producers_count{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_producers_count{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "interval": "", "intervalFactor": 1, @@ -292,7 +292,7 @@ "tableColumn": "", "targets": [ { - "expr": "sum(pulsar_subscriptions_count{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_subscriptions_count{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "interval": "", "intervalFactor": 1, @@ -374,7 +374,7 @@ "tableColumn": "", "targets": [ { - "expr": "sum(pulsar_consumers_count{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_consumers_count{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "interval": "", "intervalFactor": 1, @@ -456,7 +456,7 @@ "tableColumn": "", "targets": [ { - "expr": "sum(pulsar_msg_backlog{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_msg_backlog{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "interval": "", "intervalFactor": 1, @@ -538,7 +538,7 @@ "tableColumn": "", "targets": [ { - "expr": "sum(pulsar_storage_size{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_storage_size{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "interval": "", "intervalFactor": 1, @@ -607,11 +607,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_rate_in{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) by (cluster, namespace)", + "expr": "sum(pulsar_rate_in{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) by (cluster, namespace)", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{cluster}} - {{namespace}}", + "legendFormat": "{{ '{{cluster}} - {{namespace}}' }}", "metric": "pulsar_rate_in", "refId": "A", "step": 10 @@ -694,10 +694,10 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_rate_out{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) by (cluster, namespace)", + "expr": "sum(pulsar_rate_out{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) by (cluster, namespace)", "format": "time_series", "intervalFactor": 2, - "legendFormat": "{{cluster}} - {{namespace}}", + "legendFormat": "{{ '{{cluster}} - {{namespace}}' }}", "metric": "pulsar_rate_out", "refId": "A", "step": 10 @@ -780,11 +780,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_throughput_in{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) by (cluster, namespace)", + "expr": "sum(pulsar_throughput_in{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) by (cluster, namespace)", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{cluster}} - {{namespace}}", + "legendFormat": "{{ '{{cluster}} - {{namespace}}' }}", "metric": "pulsar_throughput_in", "refId": "A", "step": 10 @@ -869,11 +869,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_throughput_out{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) by (cluster, namespace)", + "expr": "sum(pulsar_throughput_out{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) by (cluster, namespace)", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{cluster}} - {{namespace}}", + "legendFormat": "{{ '{{cluster}} - {{namespace}}' }}", "metric": "pulsar_throughput_out", "refId": "A", "step": 10 @@ -957,7 +957,7 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_topics_count{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_topics_count{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -967,7 +967,7 @@ "step": 10 }, { - "expr": "sum(pulsar_producers_count{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_producers_count{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -977,7 +977,7 @@ "step": 10 }, { - "expr": "sum(pulsar_subscriptions_count{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_subscriptions_count{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "intervalFactor": 2, "legendFormat": "subscriptions", @@ -986,7 +986,7 @@ "step": 10 }, { - "expr": "sum(pulsar_consumers_count{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_consumers_count{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "intervalFactor": 2, "legendFormat": "consumers", @@ -1075,11 +1075,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_msg_backlog{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) by (cluster, namespace)", + "expr": "sum(pulsar_msg_backlog{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) by (cluster, namespace)", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{cluster}} - {{namespace}}", + "legendFormat": "{{ '{{cluster}} - {{namespace}}' }}", "metric": "pulsar_msg_backlog", "refId": "A", "step": 10 @@ -1194,7 +1194,7 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_storage_write_latency_le_0_5{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_storage_write_latency_le_0_5{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1204,7 +1204,7 @@ "step": 10 }, { - "expr": "sum(pulsar_storage_write_latency_le_1{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_storage_write_latency_le_1{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1214,7 +1214,7 @@ "step": 10 }, { - "expr": "sum(pulsar_storage_write_latency_le_5{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_storage_write_latency_le_5{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1224,7 +1224,7 @@ "step": 10 }, { - "expr": "sum(pulsar_storage_write_latency_le_10{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_storage_write_latency_le_10{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1234,7 +1234,7 @@ "step": 10 }, { - "expr": "sum(pulsar_storage_write_latency_le_20{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_storage_write_latency_le_20{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1244,7 +1244,7 @@ "step": 10 }, { - "expr": "sum(pulsar_storage_write_latency_le_50{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_storage_write_latency_le_50{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1254,7 +1254,7 @@ "step": 10 }, { - "expr": "sum(pulsar_storage_write_latency_le_100{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_storage_write_latency_le_100{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "hide": false, "interval": "", @@ -1265,7 +1265,7 @@ "step": 10 }, { - "expr": "sum(pulsar_storage_write_latency_le_200{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_storage_write_latency_le_200{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "intervalFactor": 2, "legendFormat": "100 - 200 ms", @@ -1274,7 +1274,7 @@ "step": 10 }, { - "expr": "sum(pulsar_storage_write_latency_le_1000{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_storage_write_latency_le_1000{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "intervalFactor": 2, "legendFormat": "200 ms - 1 s", @@ -1283,7 +1283,7 @@ "step": 10 }, { - "expr": "sum(pulsar_storage_write_latency_overflow{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_storage_write_latency_overflow{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1370,7 +1370,7 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_storage_size{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_storage_size{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1459,7 +1459,7 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_storage_write_latency_count{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_storage_write_latency_count{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1547,7 +1547,7 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_storage_read_latency_count{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_storage_read_latency_count{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1639,7 +1639,7 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_entry_size_le_128{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_entry_size_le_128{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1649,7 +1649,7 @@ "step": 10 }, { - "expr": "sum(pulsar_entry_size_le_512{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_entry_size_le_512{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1659,7 +1659,7 @@ "step": 10 }, { - "expr": "sum(pulsar_entry_size_le_1_kb{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_entry_size_le_1_kb{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1669,7 +1669,7 @@ "step": 10 }, { - "expr": "sum(pulsar_entry_size_le_2_kb{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_entry_size_le_2_kb{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1679,7 +1679,7 @@ "step": 10 }, { - "expr": "sum(pulsar_entry_size_le_4_kb{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_entry_size_le_4_kb{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1689,7 +1689,7 @@ "step": 10 }, { - "expr": "sum(pulsar_entry_size_le_16_kb{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_entry_size_le_16_kb{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1699,7 +1699,7 @@ "step": 10 }, { - "expr": "sum(pulsar_entry_size_le_100_kb{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_entry_size_le_100_kb{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1709,7 +1709,7 @@ "step": 10 }, { - "expr": "sum(pulsar_entry_size_le_1_mb{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_entry_size_le_1_mb{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1719,7 +1719,7 @@ "step": 10 }, { - "expr": "sum(pulsar_entry_size_overflow{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) / 60.0", + "expr": "sum(pulsar_entry_size_overflow{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) / 60.0", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -1820,11 +1820,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_replication_rate_in{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\", remote_cluster!=\"local\"}) by (cluster, remote_cluster)", + "expr": "sum(pulsar_replication_rate_in{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\", remote_cluster!=\"local\"}) by (cluster, remote_cluster)", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{remote_cluster}} → {{cluster}}", + "legendFormat": "{{ '{{remote_cluster}} → {{cluster}}' }}", "metric": "pulsar_rate_in", "refId": "A", "step": 10 @@ -1907,10 +1907,10 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_replication_rate_out{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"})", + "expr": "sum(pulsar_replication_rate_out{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"})", "format": "time_series", "intervalFactor": 2, - "legendFormat": "{{cluster}} → {{remote_cluster}}", + "legendFormat": "{{ '{{cluster}} → {{remote_cluster}}' }}", "metric": "pulsar_rate", "refId": "A", "step": 10 @@ -1993,10 +1993,10 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_replication_backlog{cluster=~\"$cluster\", job=~\"broker\", namespace=~\"$namespace\"}) by (cluster, remote_cluster)", + "expr": "sum(pulsar_replication_backlog{cluster=~\"$cluster\", job=~\".*broker\", namespace=~\"$namespace\"}) by (cluster, remote_cluster)", "format": "time_series", "intervalFactor": 2, - "legendFormat": "{{cluster}} → {{remote_cluster}}", + "legendFormat": "{{ '{{cluster}} → {{remote_cluster}}' }}", "metric": "pulsar_replication_backlog", "refId": "A", "step": 10 diff --git a/dashboards/node.json b/dashboards/node.json.j2 similarity index 99% rename from dashboards/node.json rename to dashboards/node.json.j2 index 600505c..d8ad247 100644 --- a/dashboards/node.json +++ b/dashboards/node.json.j2 @@ -482,7 +482,7 @@ "expr": "sum(rate(node_cpu_seconds_total{instance=\"$instance\"}[$interval])) by (mode) * 100 / count(node_cpu_seconds_total{instance=\"$instance\"}) by (mode) or sum(irate(node_cpu_seconds_total{instance=\"$instance\"}[5m])) by (mode) * 100 / count(node_cpu_seconds_total{instance=\"$instance\"}) by (mode)", "format": "time_series", "intervalFactor": 1, - "legendFormat": "{{mode}}", + "legendFormat": "{{ '{{mode}}' }}", "metric": "", "prometheusLink": "/api/datasources/proxy/1/graph#%5B%7B%22expr%22%3A%22sum(rate(node_cpu%7Binstance%3D%5C%22%24host%5C%22%7D%5B%24interval%5D))%20by%20(mode)%20*%20100%22%2C%22range_input%22%3A%223600s%22%2C%22end_input%22%3A%222015-10-22%2015%3A27%22%2C%22step_input%22%3A%22%22%2C%22stacked%22%3Atrue%2C%22tab%22%3A0%7D%5D", "refId": "A", @@ -2058,7 +2058,7 @@ "expr": "rate(node_disk_io_time_seconds_total{instance=\"$instance\"}[1m]) / 1000", "format": "time_series", "intervalFactor": 1, - "legendFormat": "{{ device }}", + "legendFormat": "{{ '{{ device }}' }}", "metric": "node_disk_io_time_ms", "prometheusLink": "/api/datasources/proxy/1/graph#%5B%7B%22expr%22%3A%22node_memory_MemTotal%7Binstance%3D%5C%22%24host%5C%22%7D%20-%20(node_memory_MemFree%7Binstance%3D%5C%22%24host%5C%22%7D%20%2B%20node_memory_Buffers%7Binstance%3D%5C%22%24host%5C%22%7D%20%2B%20node_memory_Cached%7Binstance%3D%5C%22%24host%5C%22%7D)%22%2C%22range_input%22%3A%22900s%22%2C%22end_input%22%3A%222015-10-22%2015%3A25%22%2C%22step_input%22%3A%22%22%2C%22stacked%22%3Atrue%2C%22tab%22%3A0%7D%5D", "refId": "A", @@ -2159,7 +2159,7 @@ "expr": "rate(node_disk_io_now{instance=\"$instance\"}[1m])", "format": "time_series", "intervalFactor": 1, - "legendFormat": "{{ device }}", + "legendFormat": "{{ '{{ device }}' }}", "metric": "node_disk_io_time_ms", "prometheusLink": "/api/datasources/proxy/1/graph#%5B%7B%22expr%22%3A%22node_memory_MemTotal%7Binstance%3D%5C%22%24host%5C%22%7D%20-%20(node_memory_MemFree%7Binstance%3D%5C%22%24host%5C%22%7D%20%2B%20node_memory_Buffers%7Binstance%3D%5C%22%24host%5C%22%7D%20%2B%20node_memory_Cached%7Binstance%3D%5C%22%24host%5C%22%7D)%22%2C%22range_input%22%3A%22900s%22%2C%22end_input%22%3A%222015-10-22%2015%3A25%22%2C%22step_input%22%3A%22%22%2C%22stacked%22%3Atrue%2C%22tab%22%3A0%7D%5D", "refId": "A", @@ -2260,7 +2260,7 @@ "expr": "rate(node_disk_read_time_seconds_total{instance=\"$instance\"}[1m]) / 1000 / rate(node_disk_reads_completed_total{instance=\"$instance\"}[1m])", "format": "time_series", "intervalFactor": 1, - "legendFormat": "{{ device }}", + "legendFormat": "{{ '{{ device }}' }}", "metric": "node_disk_io_time_ms", "prometheusLink": "/api/datasources/proxy/1/graph#%5B%7B%22expr%22%3A%22node_memory_MemTotal%7Binstance%3D%5C%22%24host%5C%22%7D%20-%20(node_memory_MemFree%7Binstance%3D%5C%22%24host%5C%22%7D%20%2B%20node_memory_Buffers%7Binstance%3D%5C%22%24host%5C%22%7D%20%2B%20node_memory_Cached%7Binstance%3D%5C%22%24host%5C%22%7D)%22%2C%22range_input%22%3A%22900s%22%2C%22end_input%22%3A%222015-10-22%2015%3A25%22%2C%22step_input%22%3A%22%22%2C%22stacked%22%3Atrue%2C%22tab%22%3A0%7D%5D", "refId": "A", @@ -2361,7 +2361,7 @@ "expr": "rate(node_disk_write_time_seconds_total{instance=\"$instance\"}[1m]) / 1000 / rate(node_disk_writes_completed_total{instance=\"$instance\"}[1m])", "format": "time_series", "intervalFactor": 1, - "legendFormat": "{{ device }}", + "legendFormat": "{{ '{{ device }}' }}", "metric": "node_disk_io_time_ms", "prometheusLink": "/api/datasources/proxy/1/graph#%5B%7B%22expr%22%3A%22node_memory_MemTotal%7Binstance%3D%5C%22%24host%5C%22%7D%20-%20(node_memory_MemFree%7Binstance%3D%5C%22%24host%5C%22%7D%20%2B%20node_memory_Buffers%7Binstance%3D%5C%22%24host%5C%22%7D%20%2B%20node_memory_Cached%7Binstance%3D%5C%22%24host%5C%22%7D)%22%2C%22range_input%22%3A%22900s%22%2C%22end_input%22%3A%222015-10-22%2015%3A25%22%2C%22step_input%22%3A%22%22%2C%22stacked%22%3Atrue%2C%22tab%22%3A0%7D%5D", "refId": "A", @@ -2663,7 +2663,7 @@ "expr": "rate(node_network_receive_bytes_total{instance=\"$instance\", device!=\"lo\"}[$interval]) or irate(node_network_receive_bytes_total{instance=\"$instance\", device!=\"lo\"}[5m]) ", "format": "time_series", "intervalFactor": 1, - "legendFormat": "Inbound: {{ device }}", + "legendFormat": "Inbound: {{ '{{ device }}' }}", "metric": "", "prometheusLink": "/api/datasources/proxy/1/graph#%5B%7B%22expr%22%3A%22node_memory_MemFree%7Binstance%3D%5C%22%24host%5C%22%7D%20%2B%20node_memory_Buffers%7Binstance%3D%5C%22%24host%5C%22%7D%20%2B%20node_memory_Cached%7Binstance%3D%5C%22%24host%5C%22%7D%22%2C%22range_input%22%3A%22900s%22%2C%22end_input%22%3A%222015-10-22%2015%3A25%22%2C%22step_input%22%3A%22%22%2C%22stacked%22%3Atrue%2C%22tab%22%3A0%7D%5D", "refId": "B", @@ -2677,7 +2677,7 @@ "expr": "rate(node_network_transmit_bytes_total{instance=\"$instance\", device!=\"lo\"}[$interval]) or irate(node_network_transmit_bytes_total{instance=\"$instance\", device!=\"lo\"}[5m])", "format": "time_series", "intervalFactor": 1, - "legendFormat": "Outbound: {{ device }}", + "legendFormat": "Outbound: {{ '{{ device }}' }}", "metric": "", "prometheusLink": "/api/datasources/proxy/1/graph#%5B%7B%22expr%22%3A%22node_memory_MemTotal%7Binstance%3D%5C%22%24host%5C%22%7D%20-%20(node_memory_MemFree%7Binstance%3D%5C%22%24host%5C%22%7D%20%2B%20node_memory_Buffers%7Binstance%3D%5C%22%24host%5C%22%7D%20%2B%20node_memory_Cached%7Binstance%3D%5C%22%24host%5C%22%7D)%22%2C%22range_input%22%3A%22900s%22%2C%22end_input%22%3A%222015-10-22%2015%3A25%22%2C%22step_input%22%3A%22%22%2C%22stacked%22%3Atrue%2C%22tab%22%3A0%7D%5D", "refId": "A", diff --git a/dashboards/overview.json b/dashboards/overview.json.j2 similarity index 95% rename from dashboards/overview.json rename to dashboards/overview.json.j2 index d688952..b711d68 100644 --- a/dashboards/overview.json +++ b/dashboards/overview.json.j2 @@ -299,7 +299,7 @@ "tableColumn": "", "targets": [ { - "expr": "count(count(up{job=\"zookeeper\"}) by (instance))", + "expr": "count(count(up{job=~\".*zookeeper\"}) by (instance))", "format": "time_series", "intervalFactor": 2, "legendFormat": "", @@ -380,7 +380,7 @@ "tableColumn": "", "targets": [ { - "expr": "count(count(up{job=\"bookie\"}) by (instance))", + "expr": "count(count(up{job=~\".*bookie\"}) by (instance))", "format": "time_series", "intervalFactor": 2, "legendFormat": "", @@ -461,7 +461,7 @@ "tableColumn": "Value", "targets": [ { - "expr": "count(count(up{job=\"broker\"}) by (instance))", + "expr": "count(count(up{job=~\".*broker\"}) by (instance))", "format": "time_series", "instant": true, "intervalFactor": 1, @@ -543,7 +543,7 @@ "tableColumn": "", "targets": [ { - "expr": "count(count(up{job=\"proxy\"}) by (instance))", + "expr": "count(count(up{job=~\".*proxy\"}) by (instance))", "format": "time_series", "intervalFactor": 2, "legendFormat": "", @@ -624,7 +624,7 @@ "tableColumn": "", "targets": [ { - "expr": "sum(pulsar_storage_size{job=~\"broker\"}) by (cluster)", + "expr": "sum(pulsar_storage_size{job=~\".*broker\"}) by (cluster)", "format": "time_series", "intervalFactor": 2, "legendFormat": "", @@ -705,7 +705,7 @@ "tableColumn": "", "targets": [ { - "expr": "sum(pulsar_msg_backlog{job=~\"broker\"}) by (cluster)", + "expr": "sum(pulsar_msg_backlog{job=~\".*broker\"}) by (cluster)", "format": "time_series", "intervalFactor": 2, "legendFormat": "", @@ -950,7 +950,7 @@ "tableColumn": "", "targets": [ { - "expr": "100 * count(up{job=\"zookeeper\"} == 1) / count(up{job=\"zookeeper\"})", + "expr": "100 * count(up{job=~\".*zookeeper\"} == 1) / count(up{job=~\".*zookeeper\"})", "format": "time_series", "intervalFactor": 2, "legendFormat": "", @@ -1031,7 +1031,7 @@ "tableColumn": "", "targets": [ { - "expr": "100 * count(up{job=\"bookie\"} == 1) / count(up{job=\"bookie\"})", + "expr": "100 * count(up{job=~\".*bookie\"} == 1) / count(up{job=~\".*bookie\"})", "format": "time_series", "intervalFactor": 2, "legendFormat": "", @@ -1112,7 +1112,7 @@ "tableColumn": "", "targets": [ { - "expr": "100 * count(up{job=\"broker\"} == 1) / count(up{job=\"broker\"})", + "expr": "100 * count(up{job=~\".*broker\"} == 1) / count(up{job=~\".*broker\"})", "format": "time_series", "intervalFactor": 2, "legendFormat": "", @@ -1193,7 +1193,7 @@ "tableColumn": "", "targets": [ { - "expr": "100 * count(up{job=\"proxy\"} == 1) / count(up{job=\"proxy\"})", + "expr": "100 * count(up{job=~\".*proxy\"} == 1) / count(up{job=~\".*proxy\"})", "format": "time_series", "intervalFactor": 2, "legendFormat": "", @@ -1263,10 +1263,10 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_storage_size{job=~\"broker\"}) by (cluster)", + "expr": "sum(pulsar_storage_size{job=~\".*broker\"}) by (cluster)", "format": "time_series", "intervalFactor": 2, - "legendFormat": "{{ cluster }}", + "legendFormat": "{{ '{{ cluster }}' }}", "refId": "A" } ], @@ -1348,17 +1348,17 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_rate_in{job=~\"broker\"}) by (cluster)", + "expr": "sum(pulsar_rate_in{job=~\".*broker\"}) by (cluster)", "format": "time_series", "intervalFactor": 2, - "legendFormat": "{{ cluster }} - In", + "legendFormat": "{{ '{{ cluster }}' }} - In", "refId": "A" }, { - "expr": "sum(pulsar_rate_out{job=~\"broker\"}) by (cluster)", + "expr": "sum(pulsar_rate_out{job=~\".*broker\"}) by (cluster)", "format": "time_series", "intervalFactor": 1, - "legendFormat": "{{ cluster }} - Out", + "legendFormat": "{{ '{{ cluster }}' }} - Out", "refId": "B" } ], @@ -1476,11 +1476,11 @@ ], "targets": [ { - "expr": " topk(10, sum(pulsar_msg_backlog{job=~\"broker\"}) by (topic))", + "expr": " topk(10, sum(pulsar_msg_backlog{job=~\".*broker\"}) by (topic))", "format": "table", "instant": true, "intervalFactor": 2, - "legendFormat": "{{ topic }}", + "legendFormat": "{{ '{{ topic }}' }}", "refId": "A" } ], @@ -1525,10 +1525,10 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_msg_backlog{job=~\"broker\"}) by (cluster)", + "expr": "sum(pulsar_msg_backlog{job=~\".*broker\"}) by (cluster)", "format": "time_series", "intervalFactor": 2, - "legendFormat": "{{ cluster }}", + "legendFormat": "{{ '{{ cluster }}' }}", "refId": "A" } ], @@ -1610,17 +1610,17 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_throughput_in{job=~\"broker\"}) by (cluster)", + "expr": "sum(pulsar_throughput_in{job=~\".*broker\"}) by (cluster)", "format": "time_series", "intervalFactor": 2, - "legendFormat": "{{ cluster }} - In", + "legendFormat": "{{ '{{ cluster }}' }} - In", "refId": "A" }, { - "expr": "sum(pulsar_throughput_out{job=~\"broker\"}) by (cluster)", + "expr": "sum(pulsar_throughput_out{job=~\".*broker\"}) by (cluster)", "format": "time_series", "intervalFactor": 1, - "legendFormat": "{{ cluster }} - Out", + "legendFormat": "{{ '{{ cluster }}' }} - Out", "refId": "B" } ], @@ -1716,7 +1716,7 @@ "expr": "100 * (1 - (sum(increase(node_cpu_seconds_total{mode=\"idle\"}[1m])) by (instance)\n/ \nsum(increase(node_cpu_seconds_total[1m])) by (instance)))", "format": "time_series", "intervalFactor": 1, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{ instance }}' }}", "refId": "B" } ], @@ -1802,7 +1802,7 @@ "expr": "(node_memory_MemTotal_bytes - node_memory_MemFree_bytes - node_memory_Buffers_bytes - node_memory_Cached_bytes) / node_memory_MemTotal_bytes * 100 ", "format": "time_series", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{ instance }}' }}", "refId": "A" } ], diff --git a/dashboards/proxy.json b/dashboards/proxy.json.j2 similarity index 87% rename from dashboards/proxy.json rename to dashboards/proxy.json.j2 index 6de0bfe..53653f8 100644 --- a/dashboards/proxy.json +++ b/dashboards/proxy.json.j2 @@ -1,3 +1,14 @@ +{%- if PULSAR_CUSTOM_PROMETHEUS not in [ '','no','No','NO','na','NA','false','False','0' ] %} +{#- +If custom change "instance" key to "pod" and "cluster" to "container" +This will make graph ledgends display the pod name instead of IP and port information +#} + {%- set CONTEXT = "pod" %} + {%- set CLUSTER_OBJ = "container" %} +{%- else %} + {%- set CONTEXT = "instance" %} + {%- set CLUSTER_OBJ = "cluster" %} +{%- endif -%} { "__inputs": [ { @@ -88,11 +99,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pulsar_proxy_active_connections{cluster=~\"$cluster\", job=~\"proxy\", instance=~\"$instance\"}) by (instance)", + "expr": "sum(pulsar_proxy_active_connections{{ '{' }}{{ CLUSTER_OBJ }}=~\"$cluster\", job=~\".*proxy\", {{ CONTEXT }}=~\"$instance\"}) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -175,11 +186,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(rate(pulsar_proxy_new_connections{cluster=~\"$cluster\", job=~\"proxy\", instance=~\"$instance\"}[30s])) by (instance)", + "expr": "sum(rate(pulsar_proxy_new_connections{{ '{' }}{{ CLUSTER_OBJ }}=~\"$cluster\", job=~\".*proxy\", {{ CONTEXT }}=~\"$instance\"}[30s])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -262,11 +273,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(rate(pulsar_proxy_rejected_connections{cluster=~\"$cluster\", job=~\"proxy\", instance=~\"$instance\"}[30s])) by (instance)", + "expr": "sum(rate(pulsar_proxy_rejected_connections{{ '{' }}{{ CLUSTER_OBJ }}=~\"$cluster\", job=~\".*proxy\", {{ CONTEXT }}=~\"$instance\"}[30s])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -348,11 +359,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(rate(pulsar_proxy_binary_ops{cluster=~\"$cluster\", job=~\"proxy\", instance=~\"$instance\"}[1m])) by (instance)", + "expr": "sum(rate(pulsar_proxy_binary_ops{{ '{' }}{{ CLUSTER_OBJ }}=~\"$cluster\", job=~\".*proxy\", {{ CONTEXT }}=~\"$instance\"}[1m])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A" } ], @@ -433,11 +444,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(rate(pulsar_proxy_binary_ops{cluster=~\"$cluster\", job=~\"proxy\", instance=~\"$instance\"}[1m])) by (instance)", + "expr": "sum(rate(pulsar_proxy_binary_ops{{ '{' }}{{ CLUSTER_OBJ }}=~\"$cluster\", job=~\".*proxy\", {{ CONTEXT }}=~\"$instance\"}[1m])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A" } ], @@ -518,10 +529,10 @@ "steppedLine": false, "targets": [ { - "expr": "sum(rate(jetty_requests_total{cluster=~\"$cluster\", instance=~\"$instance\"}[1m])) by (instance)", + "expr": "sum(rate(jetty_requests_total{{ '{' }}{{ CLUSTER_OBJ }}=~\"$cluster\", {{ CONTEXT }}=~\"$instance\"}[1m])) by ({{ CONTEXT }})", "format": "time_series", "intervalFactor": 1, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "B" } ], @@ -603,11 +614,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(rate(pulsar_proxy_lookup_requests{cluster=~\"$cluster\", job=~\"proxy\", instance=~\"$instance\"}[1m])) by (instance)", + "expr": "sum(rate(pulsar_proxy_lookup_requests{{ '{' }}{{ CLUSTER_OBJ }}=~\"$cluster\", job=~\".*proxy\", {{ CONTEXT }}=~\"$instance\"}[1m])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -690,11 +701,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(rate(pulsar_proxy_partitions_metadata_requests{cluster=~\"$cluster\", job=~\"proxy\", instance=~\"$instance\"}[1m])) by (instance)", + "expr": "sum(rate(pulsar_proxy_partitions_metadata_requests{{ '{' }}{{ CLUSTER_OBJ }}=~\"$cluster\", job=~\".*proxy\", {{ CONTEXT }}=~\"$instance\"}[1m])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -777,11 +788,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(rate(pulsar_proxy_get_topics_of_namespace_requests{cluster=~\"$cluster\", job=~\"proxy\", instance=~\"$instance\"}[1m])) by (instance)", + "expr": "sum(rate(pulsar_proxy_get_topics_of_namespace_requests{{ '{' }}{{ CLUSTER_OBJ }}=~\"$cluster\", job=~\".*proxy\", {{ CONTEXT }}=~\"$instance\"}[1m])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -864,11 +875,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(rate(pulsar_proxy_rejected_lookup_requests{cluster=~\"$cluster\", job=~\"proxy\", instance=~\"$instance\"}[1m])) by (instance)", + "expr": "sum(rate(pulsar_proxy_rejected_lookup_requests{{ '{' }}{{ CLUSTER_OBJ }}=~\"$cluster\", job=~\".*proxy\", {{ CONTEXT }}=~\"$instance\"}[1m])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -951,11 +962,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(rate(pulsar_proxy_rejected_partitions_metadata_requests{cluster=~\"$cluster\", job=~\"proxy\", instance=~\"$instance\"}[1m])) by (instance)", + "expr": "sum(rate(pulsar_proxy_rejected_partitions_metadata_requests{{ '{' }}{{ CLUSTER_OBJ }}=~\"$cluster\", job=~\".*proxy\", {{ CONTEXT }}=~\"$instance\"}[1m])) by ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -1038,11 +1049,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(\n rate(\n pulsar_proxy_rejected_get_topics_of_namespace_requests{\n cluster=~\"$cluster\", job=~\"proxy\", \n instance=~\"$instance\"}[1m]\n )\n ) \nby (instance)", + "expr": "sum(\n rate(\n pulsar_proxy_rejected_get_topics_of_namespace_requests{\n {{ CLUSTER_OBJ }}=~\"$cluster\", job=~\".*proxy\", \n {{ CONTEXT }}=~\"$instance\"}[1m]\n )\n ) \nby ({{ CONTEXT }})", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "A", "step": 2 } @@ -1106,9 +1117,9 @@ "multi": false, "name": "cluster", "options": [], - "query": "pulsar_proxy_active_connections{cluster=~\".+\", job=~\"proxy\"}", + "query": "pulsar_proxy_active_connections{{ '{' }}{{ CLUSTER_OBJ }}=~\".+\", job=~\".*proxy\"}", "refresh": 2, - "regex": "/.*[^_]cluster=\\\"([^\\\"]+)\\\".*/", + "regex": "/.*[^_]{{ CLUSTER_OBJ }}=\\\"([^\\\"]+)\\\".*/", "skipUrlSync": false, "sort": 1, "tagValuesQuery": "", @@ -1127,9 +1138,9 @@ "multi": true, "name": "instance", "options": [], - "query": "pulsar_proxy_active_connections{instance=~\".+\", job=~\"proxy\"}", + "query": "pulsar_proxy_active_connections{{ '{' }}{{ CONTEXT }}=~\".+\", job=~\".*proxy\"}", "refresh": 2, - "regex": "/.*[^_]instance=\\\"([^\\\"]+)\\\".*/", + "regex": "/.*[^_]{{ CONTEXT }}=\\\"([^\\\"]+)\\\".*/", "skipUrlSync": false, "sort": 1, "tagValuesQuery": "", diff --git a/dashboards/topic.json b/dashboards/topic.json.j2 similarity index 98% rename from dashboards/topic.json rename to dashboards/topic.json.j2 index d3e70b4..3a8d4b0 100644 --- a/dashboards/topic.json +++ b/dashboards/topic.json.j2 @@ -92,7 +92,7 @@ "hide": false, "interval": "", "intervalFactor": 2, - "legendFormat": "{{cluster}} - {{namespace}}", + "legendFormat": "{{ '{{cluster}} - {{namespace}}' }}", "metric": "pulsar_rate_in", "refId": "A", "step": 10 @@ -180,7 +180,7 @@ "expr": "pulsar_subscription_msg_rate_out{cluster=~\"$cluster\", namespace=~\"$namespace\", topic=~\"$topic\"}", "format": "time_series", "intervalFactor": 2, - "legendFormat": "{{subscription}}", + "legendFormat": "{{ '{{subscription}}' }}", "metric": "pulsar_rate_out", "refId": "A", "step": 10 @@ -267,7 +267,7 @@ "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{cluster}} - {{namespace}}", + "legendFormat": "{{ '{{cluster}} - {{namespace}}' }}", "metric": "pulsar_throughput_in", "refId": "A", "step": 10 @@ -357,7 +357,7 @@ "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{subscription}}", + "legendFormat": "{{ '{{subscription}}' }}", "metric": "pulsar_throughput_out", "refId": "A", "step": 10 @@ -556,7 +556,7 @@ "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{subscription}}", + "legendFormat": "{{ '{{subscription}}' }}", "metric": "pulsar_msg_backlog", "refId": "A", "step": 10 @@ -1072,7 +1072,7 @@ "multi": false, "name": "cluster", "options": [], - "query": "{cluster=~\".+\"}", + "query": "pulsar_topics_count{cluster=~\".+\"}", "refresh": 1, "regex": "/.*[^_]cluster=\\\"([^\\\"]+)\\\".*/", "sort": 1, @@ -1092,7 +1092,7 @@ "multi": false, "name": "namespace", "options": [], - "query": "{namespace=~\".+\"}", + "query": "pulsar_topics_count{namespace=~\".+\"}", "refresh": 2, "regex": "/.*namespace=\\\"([^\\\"]+)\\\".*/", "sort": 1, @@ -1112,7 +1112,7 @@ "multi": false, "name": "topic", "options": [], - "query": "{topic=~\".+\"}", + "query": "pulsar_topics_count{topic=~\".+\"}", "refresh": 2, "regex": "/.*topic=\\\"([^\\\"]+)\\\".*/", "sort": 1, diff --git a/dashboards/zookeeper.json b/dashboards/zookeeper.json.j2 similarity index 93% rename from dashboards/zookeeper.json rename to dashboards/zookeeper.json.j2 index 8b9b303..f6f02b1 100644 --- a/dashboards/zookeeper.json +++ b/dashboards/zookeeper.json.j2 @@ -1,3 +1,12 @@ +{%- if PULSAR_CUSTOM_PROMETHEUS not in [ '','no','No','NO','na','NA','false','False','0' ] %} +{#- +If custom change "instance" key to "pod" +This will make graph ledgends display the pod name instead of IP and port information +#} + {%- set CONTEXT = "pod" %} +{%- else %} + {%- set CONTEXT = "instance" %} +{%- endif -%} { "__inputs": [ { @@ -130,7 +139,7 @@ "tableColumn": "", "targets": [ { - "expr": "sum(zookeeper_server_znode_count{job=~\"$job\", instance=~\"$instance\"})", + "expr": "sum(zookeeper_server_znode_count{job=~\"$job\", {{ CONTEXT }}=~\"$instance\"})", "format": "time_series", "intervalFactor": 1, "legendFormat": "znode count", @@ -211,7 +220,7 @@ "tableColumn": "", "targets": [ { - "expr": "sum(zookeeper_server_watches_count{job=~\"$job\", instance=~\"$instance\"})", + "expr": "sum(zookeeper_server_watches_count{job=~\"$job\", {{ CONTEXT }}=~\"$instance\"})", "format": "time_series", "intervalFactor": 1, "refId": "A" @@ -291,7 +300,7 @@ "tableColumn": "", "targets": [ { - "expr": "sum(zookeeper_server_ephemerals_count{job=~\"$job\", instance=~\"$instance\"})", + "expr": "sum(zookeeper_server_ephemerals_count{job=~\"$job\", {{ CONTEXT }}=~\"$instance\"})", "format": "time_series", "intervalFactor": 1, "refId": "A" @@ -371,7 +380,7 @@ "tableColumn": "", "targets": [ { - "expr": "sum(zookeeper_server_data_size_bytes{job=~\"$job\", instance=~\"$instance\"})", + "expr": "sum(zookeeper_server_data_size_bytes{job=~\"$job\", {{ CONTEXT }}=~\"$instance\"})", "format": "time_series", "intervalFactor": 1, "refId": "A" @@ -451,7 +460,7 @@ "tableColumn": "", "targets": [ { - "expr": "sum(zookeeper_server_connections{job=~\"$job\", instance=~\"$instance\"})", + "expr": "sum(zookeeper_server_connections{job=~\"$job\", {{ CONTEXT }}=~\"$instance\"})", "format": "time_series", "intervalFactor": 1, "refId": "A" @@ -522,10 +531,10 @@ "steppedLine": false, "targets": [ { - "expr": "irate(zookeeper_server_requests_latency_ms_count{job=~\"$job\", instance=~\"$instance\", type=\"write\"}[30s])", + "expr": "irate(zookeeper_server_requests_latency_ms_count{job=~\"$job\", {{ CONTEXT }}=~\"$instance\", type=\"write\"}[30s])", "format": "time_series", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "refId": "B" } ], @@ -607,11 +616,11 @@ "steppedLine": false, "targets": [ { - "expr": "irate(zookeeper_server_requests_latency_ms_count{job=~\"$job\", instance=~\"$instance\", type=\"read\"}[30s])", + "expr": "irate(zookeeper_server_requests_latency_ms_count{job=~\"$job\", {{ CONTEXT }}=~\"$instance\", type=\"read\"}[30s])", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "metric": "zookeeper_server_requests_latency_ms_count", "refId": "A", "step": 10 @@ -695,11 +704,11 @@ "steppedLine": false, "targets": [ { - "expr": "zookeeper_server_requests_latency_ms{job=~\"$job\", instance=~\"$instance\", type=\"write\", quantile=\"0.99\"}", + "expr": "zookeeper_server_requests_latency_ms{job=~\"$job\", {{ CONTEXT }}=~\"$instance\", type=\"write\", quantile=\"0.99\"}", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "metric": "zookeeper_server_requests_latency_ms_count", "refId": "A", "step": 10 @@ -784,11 +793,11 @@ "steppedLine": false, "targets": [ { - "expr": "zookeeper_server_requests_latency_ms{job=~\"$job\", instance=~\"$instance\", type=\"read\", quantile=\"0.99\"}", + "expr": "zookeeper_server_requests_latency_ms{job=~\"$job\", {{ CONTEXT }}=~\"$instance\", type=\"read\", quantile=\"0.99\"}", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{instance}}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "metric": "zookeeper_server_requests_latency_ms_count", "refId": "A", "step": 10 @@ -873,11 +882,11 @@ "steppedLine": false, "targets": [ { - "expr": "sum(irate(zookeeper_server_requests{job=~\"$job\", instance=~\"$instance\"}[30s])) by (type)", + "expr": "sum(irate(zookeeper_server_requests{job=~\"$job\", {{ CONTEXT }}=~\"$instance\"}[30s])) by (type)", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{type}}", + "legendFormat": "{{ '{{type}}' }}", "metric": "zookeeper_server_requests_latency_ms_count", "refId": "A", "step": 4 @@ -961,11 +970,11 @@ "steppedLine": false, "targets": [ { - "expr": "zookeeper_server_znode_count{job=~\"$job\", instance=~\"$instance\"}", + "expr": "zookeeper_server_znode_count{job=~\"$job\", {{ CONTEXT }}=~\"$instance\"}", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "metric": "zookeeper_server_requests_latency_ms_count", "refId": "A", "step": 10 @@ -1049,11 +1058,11 @@ "steppedLine": false, "targets": [ { - "expr": "zookeeper_server_data_size_bytes{job=~\"$job\", instance=~\"$instance\"}", + "expr": "zookeeper_server_data_size_bytes{job=~\"$job\", {{ CONTEXT }}=~\"$instance\"}", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "metric": "zookeeper_server_requests_latency_ms_count", "refId": "A", "step": 10 @@ -1137,11 +1146,11 @@ "steppedLine": false, "targets": [ { - "expr": "zookeeper_server_connections{job=~\"$job\", instance=~\"$instance\"}", + "expr": "zookeeper_server_connections{job=~\"$job\", {{ CONTEXT }}=~\"$instance\"}", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "metric": "zookeeper_server_requests_latency_ms_count", "refId": "A", "step": 10 @@ -1225,11 +1234,11 @@ "steppedLine": false, "targets": [ { - "expr": "zookeeper_server_watches_count{job=~\"$job\", instance=~\"$instance\"}", + "expr": "zookeeper_server_watches_count{job=~\"$job\", {{ CONTEXT }}=~\"$instance\"}", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "metric": "zookeeper_server_requests_latency_ms_count", "refId": "A", "step": 10 @@ -1313,11 +1322,11 @@ "steppedLine": false, "targets": [ { - "expr": "zookeeper_server_ephemerals_count{job=~\"$job\", instance=~\"$instance\"}", + "expr": "zookeeper_server_ephemerals_count{job=~\"$job\", {{ CONTEXT }}=~\"$instance\"}", "format": "time_series", "interval": "", "intervalFactor": 2, - "legendFormat": "{{ instance }}", + "legendFormat": "{{ '{{' }} {{ CONTEXT }} {{ '}}' }}", "metric": "zookeeper_server_requests_latency_ms_count", "refId": "A", "step": 10 @@ -1382,9 +1391,9 @@ "multi": false, "name": "job", "options": [], - "query": "{job=~\".+\"}", + "query": "zookeeper_server_znode_count{job=~\".+\"}", "refresh": 1, - "regex": "/.*[^_]job=\\\"(zookeeper)\\\".*/", + "regex": "/.*[^_]job=\\\"(.*zookeeper)\\\".*/", "skipUrlSync": false, "sort": 1, "tagValuesQuery": "", @@ -1403,9 +1412,9 @@ "multi": false, "name": "instance", "options": [], - "query": "zookeeper_server_requests{job=~\"$job\", instance=~\".+\"}", + "query": "zookeeper_server_requests{job=~\"$job\", {{ CONTEXT }}=~\".+\"}", "refresh": 2, - "regex": "/.*[^_]instance=\\\"([^\\\"]+)\\\".*/", + "regex": "/.*[^_]{{ CONTEXT }}=\\\"([^\\\"]+)\\\".*/", "skipUrlSync": false, "sort": 1, "tagValuesQuery": "", diff --git a/scripts/generate_dashboards.sh b/scripts/generate_dashboards.sh index ab86a06..909577a 100755 --- a/scripts/generate_dashboards.sh +++ b/scripts/generate_dashboards.sh @@ -25,42 +25,100 @@ DASHBOARD_HOME=`cd ${BINDIR}/..;pwd` help() { cat < + +generate_dashboards.sh + +Usage: + + Scripted options: + + 1. Pass arguments to script: + generate_dashboards.sh + + 2. Set environment variables for the following and just run generate_dashboards.sh: + - PULSAR_PROMETHEUS_URL + - PULSAR_CLUSTER + - PULSAR_CUSTOM_PROMETHEUS + - GF_LOKI_URL + - GF_LOKI_DATASOURCE_NAME + + Interactive option: + + Missing any of the above inputs or environment variables will cause a prompt for input + EOF } -# if no args specified, show usage -if [ $# -lt 2 ]; then - help; - exit 1; -fi +env_var_check() { + # Checks if either var script input or env vars are set and prompts + # for interactive input when missing + local VAR=${1} + local INPUT=${2} + if [ ! -z "$(echo ${VAR})" ] && [ ! -n "${INPUT}" ]; then + echo "${VAR} is not set!" + DEFAULT_INPUT='' + read -p "Enter a value for ${VAR}: [''] " PROMPT_INPUT + PROMPT_INPUT="${PROMPT_INPUT:-${DEFAULT_INPUT}}" + export $(echo ${VAR})=${PROMPT_INPUT} + echo "${VAR} set to: $(printenv ${VAR})" + elif [ -n "${INPUT}" ]; then + echo "Setting ${VAR} from script input." + export $(echo ${VAR})=${INPUT} + echo "${VAR} set to: $(printenv ${VAR})" + elif [ -z "$(echo ${VAR})" ]; then + echo "Using existing ${VAR} environment variable." + echo "$(echo ${VAR}) set to: $(printenv ${VAR})" + else + echo "Something went wrong trying to set ${VAR}" + help + exit 1 + fi +} -export PULSAR_PROMETHEUS_URL=$1 -export PULSAR_CLUSTER=$2 -DASHBOARDS_OUTPUT_DIR="${DASHBOARD_HOME}/target/dashboards" -if [ -d ${DASHBOARDS_OUTPUT_DIR} ]; then - rm -r ${DASHBOARDS_OUTPUT_DIR} -fi -mkdir -p ${DASHBOARDS_OUTPUT_DIR} +if [ "${1}" == 'help' ] || [ "${1}" == '--help' ] || [ "${1}" == '-h' ]; then + help +else + # Check for env vars and promt for input if missing + env_var_check PULSAR_PROMETHEUS_URL ${1} + env_var_check PULSAR_CLUSTER ${2} + env_var_check PULSAR_CUSTOM_PROMETHEUS ${3} + env_var_check GF_LOKI_URL ${4} + env_var_check GF_LOKI_DATASOURCE_NAME ${5} -DATASOURCES_OUTPUT_DIR="${DASHBOARD_HOME}/target/datasources" -if [ -d ${DATASOURCES_OUTPUT_DIR} ]; then - rm -r ${DATASOURCES_OUTPUT_DIR} -fi -mkdir -p ${DATASOURCES_OUTPUT_DIR} + DASHBOARDS_OUTPUT_DIR="${DASHBOARD_HOME}/target/dashboards" + if [ -d ${DASHBOARDS_OUTPUT_DIR} ]; then + rm -r ${DASHBOARDS_OUTPUT_DIR} + fi + mkdir -p ${DASHBOARDS_OUTPUT_DIR} -echo 'Generating Datasources ...' + DATASOURCES_OUTPUT_DIR="${DASHBOARD_HOME}/target/datasources" + if [ -d ${DATASOURCES_OUTPUT_DIR} ]; then + rm -r ${DATASOURCES_OUTPUT_DIR} + fi + mkdir -p ${DATASOURCES_OUTPUT_DIR} -# apply environment variables to pulsar datasource provisioning yaml file -cp ${DASHBOARD_HOME}/conf/provisioning/datasources.yml ${DASHBOARD_HOME}/target/datasources.yml -j2 ${DASHBOARD_HOME}/target/datasources.yml > ${DATASOURCES_OUTPUT_DIR}/pulsar.yml + echo 'Generating Datasources ...' -echo "Your pulsar data source is generated as ${DATASOURCES_OUTPUT_DIR}/pulsar.yml" + # apply environment variables to pulsar datasource provisioning yaml file + cp ${DASHBOARD_HOME}/conf/provisioning/datasources.yml ${DASHBOARD_HOME}/target/datasources.yml + j2 ${DASHBOARD_HOME}/target/datasources.yml > ${DATASOURCES_OUTPUT_DIR}/pulsar.yml -# apply environment variables to pulsar dashboards -for item in `ls ${DASHBOARD_HOME}/dashboards`; do - sed "s/{{ PULSAR_CLUSTER }}/${PULSAR_CLUSTER}/" ${DASHBOARD_HOME}/dashboards/${item} > ${DASHBOARDS_OUTPUT_DIR}/${item} -done + echo "Your pulsar data source is generated as ${DATASOURCES_OUTPUT_DIR}/pulsar.yml" -echo "Your pulsar dashboards is generarted under ${DASHBOARDS_OUTPUT_DIR}" + # apply environment variables to pulsar dashboards + for item in `ls ${DASHBOARD_HOME}/dashboards`; do + # Strip the '.j2' template file exstesion from output file name + OUTPUT_FILE=$(echo ${item} | sed 's/\.j2//') + + # Only attempt to render via jinja2 if the file is a jinja2 template + if [[ "${item}" == *".j2" ]]; then + j2 ${DASHBOARD_HOME}/dashboards/${item} > ${DASHBOARDS_OUTPUT_DIR}/${OUTPUT_FILE} + else + sed "s/{{ PULSAR_CLUSTER }}/${PULSAR_CLUSTER}/" ${DASHBOARD_HOME}/dashboards/${item} > ${DASHBOARDS_OUTPUT_DIR}/${OUTPUT_FILE} + fi + + done + + echo "Your pulsar dashboards is generarted under ${DASHBOARDS_OUTPUT_DIR}" +fi