github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/production/promtail-mixin/dashboards.libsonnet (about)

     1  local configfile = import 'config.libsonnet';
     2  local g = import 'grafana-builder/grafana.libsonnet';
     3  local loki_mixin_utils = import 'loki-mixin/dashboards/dashboard-utils.libsonnet';
     4  local utils = import 'mixin-utils/utils.libsonnet';
     5  
     6  {
     7    grafanaDashboards+: {
     8      local dashboard = (
     9        loki_mixin_utils {
    10          _config+:: configfile._config,
    11        }
    12      ),
    13      local dashboards = self,
    14  
    15      // local labelsSelector = 'cluster=~"$cluster", namespace=~"$namespace"',
    16      local labelsSelector = dashboard._config.per_cluster_label + '=~"$cluster", namespace=~"$namespace"',
    17      local quantileLabelSelector = dashboard._config.per_cluster_label + '=~"$cluster", job=~"$namespace/promtail"',
    18  
    19      'promtail.json': {
    20                         local cfg = self,
    21                       } +
    22                       dashboard.dashboard('Loki / Promtail', uid='promtail')
    23                       .addCluster()
    24                       .addTag()
    25                       .addTemplate('namespace', 'promtail_build_info{' + dashboard._config.per_cluster_label + '=~"$cluster"}', 'namespace')
    26                       .addRow(
    27                         g.row('Targets & Files')
    28                         .addPanel(
    29                           g.panel('Active Targets') +
    30                           g.queryPanel(
    31                             'sum(promtail_targets_active_total{%s})' % labelsSelector,
    32                             'Active Targets',
    33                           ),
    34                         )
    35                         .addPanel(
    36                           g.panel('Active Files') +
    37                           g.queryPanel(
    38                             'sum(promtail_files_active_total{%s})' % labelsSelector,
    39                             'Active Targets',
    40                           ),
    41                         )
    42                       )
    43                       .addRow(
    44                         g.row('IO')
    45                         .addPanel(
    46                           g.panel('Bps') +
    47                           g.queryPanel(
    48                             'sum(rate(promtail_read_bytes_total{%s}[1m]))' % labelsSelector,
    49                             'logs read',
    50                           ) +
    51                           { yaxes: g.yaxes('Bps') },
    52                         )
    53                         .addPanel(
    54                           g.panel('Lines') +
    55                           g.queryPanel(
    56                             'sum(rate(promtail_read_lines_total{%s}[1m]))' % labelsSelector,
    57                             'lines read',
    58                           ),
    59                         )
    60                       )
    61                       .addRow(
    62                         g.row('Requests')
    63                         .addPanel(
    64                           g.panel('QPS') +
    65                           g.qpsPanel('promtail_request_duration_seconds_count{%s}' % labelsSelector)
    66                         )
    67                         .addPanel(
    68                           g.panel('Latency') +
    69                           g.queryPanel(
    70                             [
    71                               'job:promtail_request_duration_seconds:99quantile{%s}' % quantileLabelSelector,
    72                               'job:promtail_request_duration_seconds:50quantile{%s}' % quantileLabelSelector,
    73                               'job:promtail_request_duration_seconds:avg{%s}' % quantileLabelSelector,
    74                             ],
    75                             ['p99', 'p50', 'avg']
    76                           )
    77                         )
    78                       ),
    79    },
    80  }