Label values have a maximum length of 4096 characters; any values longer than this will be truncated.
Explore documentation
Extracting metrics from logs
You can extract any data from your logs, and use it as a metric in Dashboards.
Manage your metrics in Sources → your source → Configure → Extract Metrics tab.
Creating metrics and labels
Add a new metric by clicking the + Metric button. Similarly, add a new label by clicking the + Label buton. Then, fill out the inputs:
Metric: Name your metric.
JSON dot notation: Extract nested fields using JSON path - e.g.
context.user.email. For more complex metrics write your own SQL expression.SQL expression: Use
JSONExtract()or any valid ClickHouse SQL expression. For example:- Extract a numeric field from your logs such as
request.duration_ms, useJSONExtract(raw, 'request', 'duration_ms', 'Nullable(Float64)'). - Extract number from message texts such as
in 12.34ms, you can usetoFloat32OrNull(extract(JSONExtractString(raw, 'message'), 'in (\d+(\.\d+)?)ms')). - Calculate approximate size of the log using
LENGTH(raw). - See all ClickHouse data types and built-in functions.
- Extract a numeric field from your logs such as
Aggregations: Choose aggregations you want to use in your queries. You can select multiple aggregations. For example, use
avgandp95to get the average and 95th percentile values.
Video tutorial on creating metrics
This short tutorial will show you how to process data from your application logs and create a custom dashboard with charts using Logs to metrics: