github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/monitoring/lib/server-comparison.libsonnet (about)

     1  local grafana = import 'grafonnet/grafana.libsonnet';
     2  
     3  
     4  {
     5    dashboard:
     6      local d = grafana.dashboard.new(
     7        'Pyroscope Server Comparison',
     8        tags=['pyroscope'],
     9        time_from='now-30m',
    10        uid='8mDG2MCwXqg9hTPT',
    11        editable='true',
    12        refresh = '5s',
    13      );
    14  
    15  
    16      d
    17      .addTemplate(
    18        grafana.template.datasource(
    19          name='PROMETHEUS_DS',
    20          query='prometheus',
    21          current='prometheus',
    22          hide='hidden',  // anything other than '' and 'label works
    23        )
    24      )
    25      .addTemplate(
    26        grafana.template.new(
    27          'instance',
    28          '$PROMETHEUS_DS',
    29          'label_values(pyroscope_build_info, instance)',
    30          // otherwise the variable may be unpopulated
    31          // eg. when prometheus/grafana/pyroscope are started at the same time
    32          refresh='time',
    33          label='instance',
    34          includeAll=if $._config.benchmark then true else false,
    35        )
    36      )
    37  
    38      .addRow(
    39        grafana.row.new(
    40          title='Meta',
    41        )
    42        .addPanel(
    43          grafana.tablePanel.new(
    44            title='',
    45            datasource='$PROMETHEUS_DS',
    46            span=12,
    47            height=10,
    48          )
    49          // they don't provide any value
    50          .hideColumn("__name__")
    51          .hideColumn("Time")
    52          .hideColumn("Value")
    53          .hideColumn("job")
    54  
    55          // somewhat useful but preferred to be hidden
    56          // to make the table cleaner
    57          .hideColumn("use_embedded_assets")
    58          .addTarget(
    59            grafana.prometheus.target(
    60              'pyroscope_build_info{%s}' % $._config.selector,
    61              instant=true,
    62              format='table',
    63            )
    64          )
    65        )
    66      )
    67  
    68  
    69      // Only useful when running benchmark
    70  
    71  
    72      .addRow(
    73        grafana.row.new(
    74          title='General',
    75        )
    76        .addPanel(
    77          grafana.graphPanel.new(
    78            'Request Latency P99',
    79            datasource='$PROMETHEUS_DS',
    80            format='seconds',
    81          )
    82          .addTarget(grafana.prometheus.target(|||
    83              histogram_quantile(0.99,
    84                sum(rate(pyroscope_http_request_duration_seconds_bucket{
    85                  instance="$instance",
    86                  handler!="/metrics",
    87                  handler!="/healthz"
    88                }[$__rate_interval]))
    89                by (le, handler)
    90              )
    91            |||,
    92            legendFormat='{{ handler }}',
    93          ))
    94        )
    95  
    96        .addPanel(
    97          grafana.graphPanel.new(
    98            'Error Rate',
    99            datasource='$PROMETHEUS_DS',
   100          )
   101          .addTarget(grafana.prometheus.target(|||
   102            sum(rate(pyroscope_http_request_duration_seconds_count
   103            {instance="$instance", code=~"5..", handler!="/metrics", handler!="/healthz"}[$__rate_interval])) by (handler)
   104            /
   105            sum(rate(pyroscope_http_request_duration_seconds_count{instance="$instance", handler!="/metrics", handler!="/healthz"}[$__rate_interval])) by (handler)
   106          |||,
   107            legendFormat='{{ handler }}',
   108          ))
   109        )
   110  
   111        .addPanel(
   112          grafana.graphPanel.new(
   113            'Throughput',
   114            datasource='$PROMETHEUS_DS',
   115          )
   116          .addTarget(grafana.prometheus.target('sum(rate(pyroscope_http_request_duration_seconds_count{instance="$instance", handler!="/metrics", handler!="/healthz"}[$__rate_interval])) by (handler)',
   117            legendFormat='{{ handler }}',
   118          ))
   119        )
   120  
   121        .addPanel(
   122          grafana.graphPanel.new(
   123            'Response Size P99',
   124            datasource='$PROMETHEUS_DS',
   125            format='bytes',
   126          )
   127          .addTarget(grafana.prometheus.target('histogram_quantile(0.95, sum(rate(pyroscope_http_response_size_bytes_bucket{instance="$instance", handler!="/metrics", handler!="/healthz"}[$__rate_interval])) by (le, handler))',
   128            legendFormat='{{ handler }}',
   129          ))
   130        )
   131  
   132        .addPanel(
   133          grafana.graphPanel.new(
   134            'CPU Utilization',
   135            datasource='$PROMETHEUS_DS',
   136            format='percent',
   137            min='0',
   138            max='100',
   139            legend_show=false,
   140          )
   141          .addTarget(
   142            grafana.prometheus.target(
   143              'process_cpu_seconds_total{instance="$instance"}',
   144            )
   145          )
   146        )
   147  
   148      )
   149  }