{
  "tags": [],
  "title": "k6 Prometheus (Native Histograms)",
  "widgets": [
    {
      "layout": {
        "x": 0,
        "y": 0,
        "width": 12,
        "height": 3
      },
      "definition": {
        "type": "timeseries",
        "title": "Performance Overview",
        "yaxis": {
          "max": "auto",
          "min": "auto",
          "label": "",
          "scale": "linear",
          "include_zero": false
        },
        "requests": [
          {
            "style": {
              "palette": "dog_classic",
              "line_type": "solid",
              "line_width": "normal"
            },
            "queries": [
              {
                "name": "query1",
                "query": "avg:k6_vus{$testid}",
                "data_source": "metrics"
              },
              {
                "name": "query2",
                "query": "sum:k6_http_reqs.count{$testid}.as_rate()",
                "data_source": "metrics"
              },
              {
                "name": "query3",
                "query": "sum:k6_http_reqs.count{$testid,expected_response:false}.as_rate()",
                "data_source": "metrics"
              }
            ],
            "formulas": [
              {
                "alias": "vus",
                "formula": "query1"
              },
              {
                "alias": "http_req_s",
                "formula": "query2"
              },
              {
                "alias": "http_req_s_errors",
                "formula": "query3"
              }
            ],
            "display_type": "line",
            "response_format": "timeseries"
          }
        ],
        "show_legend": true,
        "legend_layout": "auto",
        "legend_columns": [
          "avg",
          "min",
          "max",
          "value",
          "sum"
        ]
      }
    },
    {
      "layout": {
        "x": 0,
        "y": 3,
        "width": 12,
        "height": 3
      },
      "definition": {
        "type": "group",
        "title": "Performance Overview",
        "widgets": [
          {
            "layout": {
              "x": 0,
              "y": 0,
              "width": 3,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "HTTP requests",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:k6_http_reqs.count{$testid}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center"
            }
          },
          {
            "layout": {
              "x": 3,
              "y": 0,
              "width": 3,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "HTTP request failures",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:k6_http_reqs.count{$testid,expected_response:false}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center"
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 0,
              "width": 3,
              "height": 1
            },
            "definition": {
              "type": "query_value",
              "title": "Peak RPS",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:k6_http_reqs.count{$testid}.as_rate()",
                      "aggregator": "max",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "autoscale": true,
              "precision": 2,
              "text_align": "center",
              "custom_unit": "req/s"
            }
          },
          {
            "layout": {
              "x": 9,
              "y": 0,
              "width": 3,
              "height": 1
            },
            "definition": {
              "type": "note",
              "content": "**HTTP Request Duration**\n\nUnsupported panel (stat)\n\n- histogram_quantile uses dynamic template variable $quantile; Datadog percentile aggregators require a static quantile value\n\nOriginal PromQL:\n```\nA: histogram_quantile($quantile, sum by(le) (rate(k6_http_req_duration_seconds{testid=~\"$testid\"}[$__rate_interval])))\n```",
              "tick_pos": "50%",
              "font_size": "14",
              "show_tick": false,
              "tick_edge": "left",
              "text_align": "left",
              "has_padding": true,
              "vertical_align": "top",
              "background_color": "white"
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 1,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "Transfer Rate",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": false
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:k6_data_sent.count{$testid}.as_rate()",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "avg:k6_data_received.count{$testid}.as_rate()",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "data_sent",
                      "formula": "query1"
                    },
                    {
                      "alias": "data_received",
                      "formula": "query2"
                    }
                  ],
                  "display_type": "line",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 1,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "Iterations",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": false
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:k6_dropped_iterations.count{$testid}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "dropped_iterations",
                      "formula": "query1"
                    }
                  ],
                  "display_type": "line",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          }
        ],
        "show_title": true,
        "layout_type": "ordered"
      }
    },
    {
      "layout": {
        "x": 0,
        "y": 6,
        "width": 12,
        "height": 4
      },
      "definition": {
        "type": "group",
        "title": "HTTP",
        "widgets": [
          {
            "layout": {
              "x": 0,
              "y": 0,
              "width": 4,
              "height": 2
            },
            "definition": {
              "type": "note",
              "content": "**HTTP Latency Timings**\n\nUnsupported panel (timeseries)\n\n- histogram_quantile uses dynamic template variable $quantile; Datadog percentile aggregators require a static quantile value\n- histogram_quantile uses dynamic template variable $quantile; Datadog percentile aggregators require a static quantile value\n- histogram_quantile uses dynamic template variable $quantile; Datadog percentile aggregators require a static quantile value\n- histogram_quantile uses dynamic template variable $quantile; Datadog percentile aggregators require a static quantile value\n- histogram_quantile uses dynamic template variable $quantile; Datadog percentile aggregators require a static quantile value\n- histogram_quantile uses dynamic template variable $quantile; Datadog percentile aggregators require a static quantile value\n\nOriginal PromQL:\n```\nB: histogram_quantile($quantile, sum by(le) (rate(k6_http_req_blocked_seconds{testid=~\"$testid\"}[$__rate_interval])))\nC: histogram_quantile($quantile, sum by(le) (rate(k6_http_req_tls_handshaking_seconds{testid=~\"$testid\"}[$__rate_interval])))\nD: histogram_quantile($quantile, sum by(le) (rate(k6_http_req_sending_seconds{testid=~\"$testid\"}[$__rate_interval])))\nE: histogram_quantile($quantile, sum by(le) (rate(k6_http_req_waiting_seconds{testid=~\"$testid\"}[$__rate_interval])))\nF: histogram_quantile($quantile, sum by(le) (rate(k6_http_req_receiving_seconds{testid=~\"$testid\"}[$__rate_interval])))\nA: histogram_quantile($quantile, sum by(le) (rate(k6_http_req_duration_seconds{testid=~\"$testid\"}[$__rate_interval])))\n```",
              "tick_pos": "50%",
              "font_size": "14",
              "show_tick": false,
              "tick_edge": "left",
              "text_align": "left",
              "has_padding": true,
              "vertical_align": "top",
              "background_color": "white"
            }
          },
          {
            "layout": {
              "x": 4,
              "y": 0,
              "width": 4,
              "height": 2
            },
            "definition": {
              "type": "note",
              "content": "**HTTP Latency Stats**\n\nUnsupported panel (timeseries)\n\n- histogram_quantile uses dynamic template variable $quantile; Datadog percentile aggregators require a static quantile value\n- histogram_quantile uses dynamic template variable $quantile; Datadog percentile aggregators require a static quantile value\n- histogram_quantile uses dynamic template variable $quantile; Datadog percentile aggregators require a static quantile value\n\nOriginal PromQL:\n```\nA: histogram_quantile($quantile, sum by (le) ((rate(k6_http_req_duration_seconds{testid=~\"$testid\"}[$__rate_interval]))))\nC: histogram_quantile($quantile, sum by(le) (rate(k6_http_req_waiting_seconds{testid=~\"$testid\", expected_response=\"true\"}[$__rate_interval])))\nB: histogram_quantile($quantile, sum by(le) (rate(k6_http_req_waiting_seconds{testid=~\"$testid\", expected_response=\"false\"}[$__rate_interval])))\n```",
              "tick_pos": "50%",
              "font_size": "14",
              "show_tick": false,
              "tick_edge": "left",
              "text_align": "left",
              "has_padding": true,
              "vertical_align": "top",
              "background_color": "white"
            }
          },
          {
            "layout": {
              "x": 8,
              "y": 0,
              "width": 4,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "HTTP Request Rate",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": false
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "sum:k6_http_reqs.count{$testid}.as_rate()",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "sum:k6_http_reqs.count{$testid,expected_response:false}.as_rate()",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query3",
                      "query": "sum:k6_http_reqs.count{$testid,expected_response:true}.as_rate()",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "http_req_s",
                      "formula": "query1"
                    },
                    {
                      "alias": "http_req_s_errors",
                      "formula": "query2"
                    },
                    {
                      "alias": "http_req_s_success",
                      "formula": "query3"
                    }
                  ],
                  "display_type": "line",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 2,
              "width": 12,
              "height": 2
            },
            "definition": {
              "type": "query_table",
              "title": "Requests by URL",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "p95:k6_http_req_duration_seconds{$testid} by {name,method,status}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    },
                    {
                      "name": "query2",
                      "query": "p99:k6_http_req_duration_seconds{$testid} by {name,method,status}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "p95",
                      "limit": {
                        "count": 50,
                        "order": "desc"
                      },
                      "formula": "query1"
                    },
                    {
                      "formula": "query2"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "has_search_bar": "auto"
            }
          }
        ],
        "show_title": true,
        "layout_type": "ordered"
      }
    },
    {
      "layout": {
        "x": 0,
        "y": 10,
        "width": 12,
        "height": 3
      },
      "definition": {
        "type": "group",
        "title": "Checks",
        "widgets": [
          {
            "layout": {
              "x": 0,
              "y": 0,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "query_table",
              "title": "Checks list",
              "requests": [
                {
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:k6_checks_rate{$testid}",
                      "aggregator": "last",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "limit": {
                        "count": 50,
                        "order": "desc"
                      },
                      "formula": "query1"
                    }
                  ],
                  "response_format": "scalar"
                }
              ],
              "has_search_bar": "auto"
            }
          },
          {
            "layout": {
              "x": 6,
              "y": 0,
              "width": 6,
              "height": 2
            },
            "definition": {
              "type": "timeseries",
              "title": "Checks Success Rate (aggregate individual checks)",
              "yaxis": {
                "max": "auto",
                "min": "auto",
                "label": "",
                "scale": "linear",
                "include_zero": false
              },
              "requests": [
                {
                  "style": {
                    "palette": "dog_classic",
                    "line_type": "solid",
                    "line_width": "normal"
                  },
                  "queries": [
                    {
                      "name": "query1",
                      "query": "avg:k6_checks_rate{$testid}",
                      "data_source": "metrics"
                    }
                  ],
                  "formulas": [
                    {
                      "alias": "k6_checks_rate",
                      "formula": "query1 * 100"
                    }
                  ],
                  "display_type": "line",
                  "response_format": "timeseries"
                }
              ],
              "show_legend": true,
              "legend_layout": "auto",
              "legend_columns": [
                "avg",
                "min",
                "max",
                "value",
                "sum"
              ]
            }
          },
          {
            "layout": {
              "x": 0,
              "y": 2,
              "width": 12,
              "height": 1
            },
            "definition": {
              "type": "note",
              "content": "### Visualize other k6 results  \n\nAt the top of the dashboard, click `Add` and select `Visualization` from the dropdown menu. Choose the visualization type and input the PromQL queries for the `k6_` metric(s).\n\nAlternatively, click on the `Explore` icon on the menu bar and input the queries for the `k6_` metric(s). From `Explore`, you can add new Panels to this dashboard. \n\nNote that all <a href=\"https://k6.io/docs/using-k6/metrics/\" target=\"_blank\">k6 metrics</a> are prefixed with the `k6_` namespace when sent to Prometheus.",
              "tick_pos": "50%",
              "font_size": "14",
              "show_tick": false,
              "tick_edge": "left",
              "text_align": "left",
              "has_padding": true,
              "vertical_align": "top",
              "background_color": "white"
            }
          }
        ],
        "show_title": true,
        "layout_type": "ordered"
      }
    }
  ],
  "description": "Converted from Grafana dashboard https://grafana.com/grafana/dashboards/18030 (by k6). Visualize k6 OSS results stored in Prometheus with Native Histograms.",
  "layout_type": "ordered",
  "reflow_type": "fixed",
  "template_variables": [
    {
      "name": "testid",
      "prefix": "testid",
      "default": "*",
      "available_values": []
    },
    {
      "name": "quantile",
      "prefix": "quantile",
      "default": "0.99",
      "available_values": []
    }
  ]
}