Skip to content

Commit a5728fa

Browse files
refinement and examples
1 parent 95cd179 commit a5728fa

File tree

4 files changed

+60
-76
lines changed

4 files changed

+60
-76
lines changed
196 KB
Loading
129 KB
Loading
123 KB
Loading

explore-analyze/visualize/metric-charts.md

Lines changed: 60 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ description: Instructions and best practices for building metric charts with Kib
88

99
# Build metric charts with {{kib}}
1010

11-
Metric charts make important single values stand out on a dashboard. They're perfect for highlighting KPIs like total sales, active users, or error rates. They can show a plain number, a percentage, or a calculation like a count, sum, or average.
11+
Metric charts make important single values stand out on a dashboard. They're perfect for highlighting KPIs like total sales, active users, or error rates.
1212

13-
Metric charts are the best visualization when you need to show a single, important value and make it visible.
13+
They work with any numeric data: plain numbers, percentages, or calculations like a count, sum, or average. You can get this numeric data from numeric fields stored in your {{es}} documents, or from aggregation functions and formulas that you can apply to any type of field.
1414

1515
The best way to create metric charts in {{kib}} is with **Lens**.
1616

1717
![Metric chart representing an SLO](../images/metric-chart.png "=30%")
1818

19-
## Requirements
19+
## When to use metric charts
2020

21-
Metric charts work with any numeric data. That data can directly come from numeric fields in your data, or be the result of aggregations or formulas.
21+
Metric charts are the best visualization when you need to show a single, important value and make it visible.
2222

2323
## Build a metric chart
2424

@@ -33,7 +33,7 @@ To build a metric chart:
3333
::::
3434

3535
::::{step} Set the visualization to Metric
36-
New visualizations suggest to create **Bar** charts by default.
36+
New visualizations default to creating **Bar** charts.
3737

3838
Using the dropdown indicating **Bar**, select **Metric**.
3939
::::
@@ -49,7 +49,7 @@ Using the dropdown indicating **Bar**, select **Metric**.
4949
Refer to [](#settings) to find all data configuration options for your metric chart.
5050
::::
5151

52-
::::{step} Customize the appearance of the chart
52+
::::{step} Customize the chart with best practices
5353
Tweak the appearance of the chart to your needs. Consider the following best practices:
5454

5555
**Use color wisely**
@@ -70,67 +70,6 @@ Save your visualization by selecting **Save and return** if you're adding it fro
7070

7171
:::::
7272

73-
## Examples
74-
75-
Here are common patterns you can adapt for your own data.
76-
77-
**Executive dashboard KPI**
78-
: Display total revenue as a prominent number on an executive dashboard:
79-
80-
* **Primary metric**: `sum(sales.revenue)`
81-
* **Value format**: Currency with 1 decimal place
82-
* **Title**: "Total Revenue"
83-
* **Subtitle**: "Current Quarter"
84-
* **Color by value**: Green when above target, red when below
85-
86-
**Website traffic with trend**
87-
: Monitor current traffic and show whether it's increasing or decreasing compared to the previous period:
88-
89-
* **Primary metric**: `count()` (current week's page views)
90-
* **Secondary metric**: `count(shift='1w')` (previous week's page views)
91-
* **Trend indicator**: Dynamic coloring enabled
92-
* **Compare to**: Primary metric
93-
* **Display**: Both icon and value
94-
* **Color palette**: Green for increases (more traffic is positive)
95-
* **Title**: "Weekly Page Views"
96-
97-
**System performance by service**
98-
: Compare response times across multiple services using breakdown:
99-
100-
* **Primary metric**: `average(response_time_ms)`
101-
* **Break down by**: `service.name`
102-
* **Value format**: Number with suffix "ms"
103-
* **Title**: "Average Response Time"
104-
* **Color mapping**: Assign consistent colors to each service name
105-
* **Color by value**: Red above 500ms, yellow between 200-500ms, green below 200ms
106-
107-
**Error rate with formula**
108-
: Calculate and display error percentage using a formula:
109-
110-
* **Primary metric formula**: `count(kql='status_code >= 400') / count() * 100`
111-
* **Value format**: Percent with 2 decimals
112-
* **Title**: "Error Rate"
113-
* **Color by value**: Green below 1%, yellow between 1-5%, red above 5%
114-
115-
**Capacity utilization**
116-
: Show current usage against maximum capacity:
117-
118-
* **Primary metric**: `average(system.memory.used.bytes)`
119-
* **Maximum**: `average(system.memory.total.bytes)`
120-
* **Value format**: Bytes
121-
* **Title**: "Memory Usage"
122-
* **Color by value** (Percent mode): Green 0-70%, yellow 70-90%, red above 90%
123-
124-
**Multi-service comparison**
125-
: Create a comprehensive view with multiple services side-by-side:
126-
127-
* **Primary metric**: `count()`
128-
* **Break down by**: `service.name`
129-
* **Value format**: Number, compact values enabled
130-
* **Title**: "Request Volume by Service"
131-
* **Subtitle**: "Last Hour"
132-
* **Color mapping**: Assign brand colors to each service for consistency
133-
13473
## Advanced configurations
13574

13675
### Show trends in Metric charts [metric-trends]
@@ -177,7 +116,7 @@ To add trend indicators to your metric visualization:
177116
* The secondary metric label changes to **Difference**. You can change this by editing the **Prefix** option of the metric.
178117
* If you chose a **Display** option that shows a value, the secondary metric value is automatically updated to show the difference compared to the primary metric.
179118

180-
7. Apply your changes.
119+
8. Apply your changes.
181120

182121
The metric visualization now shows the secondary metric as a comparison with a trend indicator.
183122

@@ -195,7 +134,7 @@ Customize your metric chart to display exactly the information you need, formatt
195134

196135
**Appearance**
197136
: Define the formatting of the primary metric, including:
198-
- **Name**: By default, the chart uses the function or formula as title. It is a best practice to customize this with a readable title.
137+
- **Name**: By default, the chart uses the function or formula as title. It's a best practice to customize this with a readable title.
199138
- **Value format**: Choose to display the metric as number, percent, bytes, bits, duration, or with a custom format that you can define.
200139
- **Color by value**: Apply colors to the chart. Choose between **Static** for a unique color and **Dynamic** for using different colors based on the metric's value. By default, the color applies to the chart's background.
201140
- **Static**: Pick a color and its opacity. That color always remains the same and is independent from the metric's value.
@@ -218,7 +157,7 @@ Customize your metric chart to display exactly the information you need, formatt
218157

219158
**Appearance**
220159
: Define the formatting of the secondary metric, including:
221-
- **Name**: By default, the chart uses the function or formula as title. It is a best practice to customize this with a readable title.
160+
- **Name**: By default, the chart uses the function or formula as title. It's a best practice to customize this with a readable title.
222161
- **Value format**: Choose to display the metric as number, percent, bytes, bits, duration, or with a custom format that you can define.
223162
- **Label**: Define the label displayed next to the secondary metric. By default, the **Name** shows. You can instead show a **Custom** value or hide it by selecting **None**.
224163
- **Label position**: Choose to show the label **Before** or **After** the metric.
@@ -233,25 +172,25 @@ Customize your metric chart to display exactly the information you need, formatt
233172
:::
234173

235174
**Appearance**
236-
: Define the formatting of the secondary metric, including:
237-
- **Name**: By default, the chart uses the function or formula as title. It is a best practice to customize this with a readable title.
175+
: Define the formatting of the maximum value, including:
176+
- **Name**: It's a best practice to customize this with a readable title.
238177

239178
### Breakdown settings [breakdown-options]
240179

241180
**Data**
242181
: Split your metric into multiple tiles based on a categorical field. Each unique value creates its own tile, allowing you to compare metrics across regions, products, time periods, or any other dimensions. You can optionally specify the following options:
243182

244183
- **Number of values**: The number of tiles to show. If more values are available for the selected breakdown field, an additional tile named **Other** shows if the **Group remaining values as "Other"** advanced option is on.
245-
- **Rank by**: The dimension top values are ranked by.
184+
- **Rank by**: The dimension by which top values are ranked.
246185
- **Rank direction**: The direction to use for the ranking.
247186
- **Collapse by**: Aggregate values of the various tiles into a single number. Possible aggregation options are `None` (default), `Sum`, `Average`, `Min`, and `Max`.
248187

249188
:::{include} ../_snippets/lens-breakdown-advanced-settings.md
250189
:::
251190

252191
**Appearance**
253-
: Define the formatting of the secondary metric, including:
254-
- **Name**: By default, the chart uses the function or formula as title. It is a best practice to customize this with a readable title.
192+
: Define the formatting of the broken down view of the metric, including:
193+
- **Name**: It's a best practice to customize this with a readable title.
255194
- **Layout columns**: The number of columns used to lay out the various tiles of your metric chart.
256195

257196

@@ -271,4 +210,49 @@ When creating or editing a visualization, you can customize several appearance o
271210
: Define the **Alignment** of the secondary metric.
272211

273212
**Other**
274-
: Choose the **Icon** position.
213+
: Choose the **Icon** position.
214+
215+
216+
## Metric chart examples
217+
218+
The following examples show various configuration options that you can use for building impactful metrics.
219+
220+
**Executive dashboard KPI**
221+
: Display total revenue as a prominent number on an executive dashboard:
222+
223+
* **Title**: "Total Revenue"
224+
* **Primary metric**: `sum(sales.revenue)`
225+
* **Value format**: Currency with no decimal. You can use a custom format to add symbols such as `$`
226+
* **Subtitle**: "Current Quarter"
227+
* **Color by value**: Green when above $250,000 target, red when below
228+
* **Supporting visualization:** "Line" to show revenue evolution throughout the quarter
229+
230+
![Metric with a total revenue below the target](../images/metric-total-revenue-example.png "=70%")
231+
232+
**Website traffic with trend**
233+
: Monitor current traffic and show whether it's increasing or decreasing compared to the previous period:
234+
235+
* **Title**: "Weekly page views"
236+
* **Subtitle**: "This week"
237+
* **Primary metric**: `count()` (current week's page views)
238+
* **Secondary metric**: `count(shift='1w')` (previous week's page views)
239+
* **Color by value**: Dynamic coloring
240+
* **Compare to**: Primary metric
241+
* **Display**: Both icon and value
242+
* **Label**: "Compared to last week"
243+
* **Color palette**: Green for increases (more traffic is positive)
244+
245+
![Metric showing weekly visits with weekly comparison trend](../images/metric-website-views-weekly-trend-example.png "=70%")
246+
247+
**Sales per day of the week**
248+
: Compare revenue across days of the week using breakdown:
249+
250+
* **Title**: "Revenue per weekday"
251+
* **Primary metric**: `sum(sales.total)`
252+
* **Value format**: Currency with no decimal. You can use a custom format to add symbols such as `$`
253+
* **Color by value**: Red below $30,000, yellow between $30,000-$35,000, green above $35,000
254+
* **Break down by**: `day_of_week`
255+
* **Number of values**: `7`
256+
* **Layout columns**: `4`
257+
258+
![Metric showing revenue broken down per day of the week](../images/metric-revenue-breakdown-example.png "=70%")

0 commit comments

Comments
 (0)