github.com/thanos-io/thanos@v0.32.5/mixin/dashboards/defaults.libsonnet (about) 1 local utils = import '../lib/utils.libsonnet'; 2 { 3 local thanos = self, 4 local grafanaDashboards = super.grafanaDashboards, 5 local grafana = import 'grafonnet/grafana.libsonnet', 6 local template = grafana.template, 7 8 dashboard:: { 9 prefix: 'Thanos / ', 10 tags: error 'must provide dashboard tags', 11 timezone: 'UTC', 12 instance_name_filter: '', 13 }, 14 15 // Automatically add a uid to each dashboard based on the base64 encoding 16 // of the file name and set the timezone to be 'default'. 17 grafanaDashboards:: { 18 local component = utils.sanitizeComponentName(std.split(filename, '.')[0]), 19 20 [filename]: grafanaDashboards[filename] { 21 uid: std.md5(filename), 22 timezone: thanos.dashboard.timezone, 23 tags: thanos.dashboard.tags, 24 25 // Modify tooltip to only show a single value 26 rows: [ 27 row { 28 panels: [ 29 panel { 30 tooltip+: { 31 shared: false, 32 }, 33 } 34 for panel in super.panels 35 ], 36 } 37 for row in super.rows 38 ], 39 40 templating+: { 41 // Add optional filter to the datasource template variable 42 list: [ 43 if variable.name == 'datasource' 44 then variable { regex: thanos.dashboard.instance_name_filter } 45 else variable 46 for variable in super.list 47 ] + [ 48 template.interval( 49 'interval', 50 '5m,10m,30m,1h,6h,12h,auto', 51 label='interval', 52 current='5m', 53 ), 54 ], 55 }, 56 } { 57 templating+: { 58 list+: [ 59 template.new( 60 level, 61 '$datasource', 62 'label_values(%s, %s)' % [thanos.targetGroups[level], level], 63 label=level, 64 refresh=1, 65 sort=2, 66 ) 67 for level in std.objectFields(thanos.targetGroups) 68 ], 69 }, 70 } + if std.objectHas(thanos[component], 'selector') then { 71 templating+: { 72 local name = 'job', 73 local selector = std.join(', ', thanos.dashboard.selector + [thanos[component].selector]), 74 list+: [ 75 template.new( 76 name, 77 '$datasource', 78 'label_values(up{%s}, %s)' % [selector, name], 79 label=name, 80 refresh=1, 81 sort=2, 82 current='all', 83 allValues=null, 84 includeAll=true 85 ), 86 ], 87 }, 88 } else {} 89 for filename in std.objectFields(grafanaDashboards) 90 }, 91 }