Grafana Guide: Bar Chart, Pie, Histogram and Heatmap

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Checked on 2026-11-11 against Grafana 13.3.x.

What you build

You add four panels to the dashboard Bookshelf (guides). Two of them draw the request rate of the Bookshelf service by HTTP status as categories, a bar chart and a donut. The other two show how the response time is distributed: a histogram of the 95th percentile latency over the selected time range, and a heatmap of the Prometheus latency buckets over time.

Dashboard Bookshelf (guides) in view mode with four new panels in a grid: a bar chart and a donut of the request rate by status, a histogram of the 95th percentile latency and a heatmap of the latency buckets over time

Before you start

  • Start the Grafana profile of the hands-on lab and wait about a minute:

    cd lab
    docker compose --profile grafana up -d
  • Open http://localhost:3000, sign in as admin with the password admin, and click Skip when Grafana 13.3 asks you to update the default password.

  • Do the guide Create a dashboard and the first panel first: it creates the folder Guides and the dashboard Bookshelf (guides) that this guide extends. The previous guide, Tables, shows the same way of building a panel from an instant query.

  • The data source Prometheus is provisioned by the lab and is the default data source. The load generator sends traffic to the Bookshelf service in its default mode, which gives the queries something to draw. The latency panels need a few minutes of traffic to look good.

  • The guide was checked on Grafana Enterprise 13.3.0 (the free image, no licence key). Editing dashboards needs the Editor or Admin role of the organization; admin has it.

  • The figures are drawings of the Grafana 13.3 user interface, not screenshots, so small details can differ from your screen. A highlighted box with a number marks the control of the step with the same number.

Steps

The panel editor used here is the one shown in the map of the first dashboard guide; come back to that map when a control is not where a figure shows it. Each panel is built in the panel editor and left with Back; the dashboard is saved once at the end.

Open the dashboard and add a panel

  1. In the left navigation, click Dashboards, open the folder Guides and click Bookshelf (guides).

  2. Click Edit at the top right.

    Dashboard Bookshelf (guides) in view mode with the navigation docked: callout 1 marks the Dashboards item of the navigation and callout 2 marks the Edit button of the toolbar
  3. In the toolbar, click Add.

  4. In the Add pane of the right sidebar, click the Panel tile.

    Dashboard Bookshelf (guides) in edit mode with the Add pane of the right sidebar open: callout 3 marks the Add button of the toolbar and callout 4 marks the Panel tile of the Add pane
  5. In the Panel pane that replaces the Add pane, click Edit visualization.

Draw the request rate by status as a bar chart

  1. At the bottom of the panel editor, check that the Queries tab is selected and that Data source shows Prometheus.

  2. In query A, click Code in the Builder / Code switch.

  3. Click inside the query editor first, so that it has the focus, then type the query, which sums the request rate by HTTP status:

    sum by (status) (rate(http_server_requests_seconds_count{application="bookshelf"}[1m]))
  4. Below the editor, click the Options line to open it, then open the Format list and choose Table. A bar chart needs one row per status, not one line per series.

  5. In the same row, open the Type list and choose Instant, so that the query returns the latest rate of each status.

  6. Click Run queries.

    Panel editor on the Queries tab: the Prometheus data source is marked by callout 6, the Code option by callout 7, the typed query that sums the request rate by status by callout 8, the opened Options row shows Format set to Table (callout 9) and Type set to Instant (callout 10), and Run queries is marked by callout 11
  7. In the right column, click the All visualizations tab, then click Bar chart ("Categorical charts with group support").

    Panel editor after Run queries: the preview shows a table with the columns Time, status and Value for the statuses 200 and 404, and the All visualizations tab lists Bar chart with the description Categorical charts with group support, marked by callout 12
  8. The right column becomes the options pane, headed Bar chart. Open Panel options and type Request rate by status (bars) in Title.

  9. Open Bar chart and, in X Axis, choose the field status, so that each bar is one status code.

    Panel editor with the Bar chart options pane: the Title field holds Request rate by status (bars), marked by callout 13, and the X Axis of the Bar chart group is set to status, marked by callout 14; the preview draws one bar for 200 and a small one for 404
  10. Click Back in the header of the editor. The 13.3 panel editor has no Apply button; the panel stays on the dashboard, which is saved at the end.

Draw the same data as a donut

  1. In the toolbar, click Add.

  2. In the Add pane, click the Panel tile.

    Dashboard in edit mode after Back: the new bar chart panel sits next to the first panel, callout 16 marks the Add button of the toolbar and callout 17 marks the Panel tile of the Add pane
  3. In the Panel pane, click Edit visualization.

  4. Repeat steps 7 to 11: choose Code, type the same query, set Format to Table and Type to Instant, and click Run queries.

  5. In the right column, click All visualizations, then Pie chart ("The new core pie chart visualization").

  6. Under Panel options, type Request rate by status (donut) in Title.

  7. Open Value options and set Show to All values, so that every row of the table is a slice. With the default the panel reduces the numbers to a single value.

  8. Open Pie chart and set Pie chart type to Donut.

    Panel editor with the Pie chart options pane: the Title holds Request rate by status (donut), marked by callout 21, Show under Value options is set to All values, marked by callout 22, and Pie chart type is set to Donut, marked by callout 23; the preview draws a donut with a large slice for 200
  9. Click Back.

Show the latency distribution as a histogram

  1. Repeat steps 16 to 18: click Add, click the Panel tile and click Edit visualization.

  2. In query A, click Code.

  3. Click inside the query editor, then type the query, which computes the 95th percentile latency from the Prometheus buckets (the editor wraps the long line, as the figure shows):

    histogram_quantile(0.95, sum by (le) (rate(http_server_requests_seconds_bucket{application="bookshelf"}[1m])))
  4. Leave Format and Type at their defaults and click Run queries. The preview draws one line, the latency over time.

    Panel editor in Code mode for the third panel: the Code option is marked by callout 26, the two-line histogram_quantile query for the 95th percentile of the request latency is typed in the editor (callout 27) and Run queries is marked by callout 28
  5. In the right column, click All visualizations, then Histogram ("Distribution of values presented as a bar chart.").

  6. Under Panel options, type Latency p95 distribution in Title.

  7. Open Histogram and type 20 in Bucket count. The bars now count how many samples of the line fall into each of 20 value ranges.

    Panel editor with the Histogram options pane: the Title holds Latency p95 distribution, marked by callout 30, and Bucket count under the Histogram group is 20, marked by callout 31; the preview draws bars for ranges of latency values
  8. Click Back.

Show the latency buckets as a heatmap

  1. Repeat steps 16 to 18 once more to add the fourth panel and open its editor.

  2. In query A, click Code.

  3. Click inside the query editor, then type the query, which keeps the rate of every latency bucket as its own series:

    sum by (le) (rate(http_server_requests_seconds_bucket{application="bookshelf"}[1m]))
  4. Below the editor, click the Options line to open it, then open the Format list and choose Heatmap. Leave Type at its default.

  5. Click Run queries.

    Panel editor in Code mode for the fourth panel: the Code option is marked by callout 34, the query that sums the latency buckets by le is typed in the editor (callout 35), the opened Options row shows Format set to Heatmap (callout 36) and Run queries is marked by callout 37
  6. In the right column, click All visualizations, then Heatmap ("Like a histogram over time").

  7. Under Panel options, type Latency buckets over time in Title.

  8. Open Heatmap and set Calculate from data to No. The data already comes as buckets, so Grafana must not bucket it again.

    Panel editor with the Heatmap options pane: the Title holds Latency buckets over time, marked by callout 39, and Calculate from data under the Heatmap group is set to No, marked by callout 40; the preview draws a grid of cells whose colour grows with the request rate of each latency bucket
  9. Click Save in the header of the editor.

  10. In the Save dashboard drawer, click Save.

  11. Click Back to return to the dashboard.

  12. Click Exit edit. If Grafana 13.3.0 shows the dialog Unsaved changes, click Save and click Save again in the drawer, as in the first dashboard guide.

Check the result

Open Dashboards → Guides → Bookshelf (guides). The dashboard must show the four new panels: a bar chart and a donut with a large part for the status 200 and a small one for 404, a histogram of latency values and a heatmap whose cells are brightest in the lowest buckets.

To see the panels react, send errors, wait a minute and press Refresh; a third bar and a third slice for the status 500 appear:

curl -X POST localhost:8090/mode/failing

To move the latency panels, make the service slow instead:

curl -X POST localhost:8090/mode/slow

Restore normal traffic afterwards, and check the mode of the load generator at any time:

curl -X POST localhost:8090/mode/normal
curl localhost:8090/

Variations

  • Draw several statuses as groups of bars: add a second series to the bar chart with another query and use Stacking under Bar chart to stack them.

  • Show the share instead of the rate: set Labels under Pie chart to show the percentage on each slice.

  • Let Grafana bucket the data itself: set Calculate from data to Yes and fill X Bucket and Y Bucket under Heatmap. This also lets you try the panel with the data source TestData when the Bookshelf buckets are too thin, for example just after the lab started.

  • Change the colours of the heatmap under Colors: Mode, Scheme and Steps.

What can go wrong

Symptom Cause Fix

The bar chart or the donut shows a single bar or slice

Format is still Time series, or Show of the donut is still the default calculation, which reduces the numbers to one value.

Set Format to Table and Type to Instant, and set Show to All values under Value options.

The bar chart has no label under the bars

X Axis does not name the status field.

Open Bar chart and choose status in X Axis.

The histogram is almost empty or has one tall bar

The lab started less than a few minutes ago, so the line has few samples, or Bucket count is too high for them.

Wait for more traffic, press Refresh, and lower Bucket count.

The heatmap is empty or one solid colour

Format is not Heatmap, or Calculate from data is Yes although the data is already in buckets.

Set Format to Heatmap in the Options line and Calculate from data to No; or use TestData with Calculate from data set to Yes.

Exit edit keeps showing Unsaved changes

Grafana 13.3.0 raises the dialog even after a save.

Click Save, and Save again in the drawer; the dialog does not return once edit mode has closed.

Clean up

Keep the panels: later guides on this dashboard build on them. To remove them, open the dashboard, click Edit, open the menu of each panel and delete it, then save the dashboard.

Where to go next