Create dashboards for logging
Create dashboards to query and visualize logging data. You can define a logging query and then add it to a standard or classic dashboard.
Standard dashboards
Complete the following steps to create a standard dashboard with a query for logging:
- In the navigation menu, select Explorers > Logs Explorer.
- Write a query that returns the log data you want to view.
- Click Add to dashboard.
- In the Add to dashboard dialog, enter a name for your query. The query you defined is input in the Name field by default.
- Click create a new dashboard to create a new dashboard containing a panel with the query you defined.
- Click Add to dashboard to add the panel to your dashboard.
Observability Platform creates the dashboard with the query you defined. You can change the panel's type if you want the query to display as a different visualization.
Classic dashboards
Complete the following steps to create a classic dashboards with a query for logging.
You can use Grafana variable syntax (opens in a new tab)
in your query, such as including $varname
to interpolate values from your
dashboard. Defining variables enables dropdown menus in dashboards to better filter
your displayed data.
If you want to use variables in your query, you need to create them first. See Add a query variable (opens in a new tab) in the Grafana documentation for more information.
To create a classic dashboard with a query for logging:
-
In Logs Explorer, define your query.
-
Select your entire query and copy it to your clipboard.
-
In the navigation menu, click Dashboards to go to the Dashboards screen.
-
Add a panel to your dashboard.
-
Enter a Panel title and Description for your panel.
-
In the Query pane of your dashboard, select Chronosphere Logs from the dropdown as the query type.
-
In the Repository dropdown, select the repository you want to run your query against.
-
In the Query field, paste the query you defined. Replace any values with supported variables you want to use, such as
$varname
. -
In your query, add a pipe (
|
) and a supported query function (opens in a new tab) that maps to the visualization you want to display.For example, if you want to display a time chart, add
| timechart()
to your query:service = "payment-gateway-svc" | severity = ERROR | timechart()
-
Click Apply to apply your changes, and then click Save dashboard.
Add a legend to classic dashboards
You can use Grafana field overrides (opens in a new tab) to add a legend to classic dashboards that include a LogScale query. The LogScale Query Language doesn't support a legend format. Use a field override to change the name displayed on your dashboard.
For example, your dashboard might contain a field named _count DELETE
that you want
to display as DELETE
in the dashboard legend. Edit the dashboard panel and create a
field override to change the display name for that field in the dashboard legend.
Express multiple queries with variables
You can create multiple queries in a dashboard, and use an expression to evaluate a math operator between the values that result from the two logs. These queries require a variable, which you create in your dashboard and then include in the query.
-
Create a variable to reference in your dashboard. For example, a variable named
severity
that you reference for severity values such asINFO
,WARNING
, andERROR
. -
Write a query that references your variable and test it in Logs Explorer.
To write a compound query including a variable, surround the entire query in brackets
[]
and include the variable you created in your query. You can then take the output of the math operator in your first query and use it in your second query.For example, the following query includes the
$severity
variable, performs twocount()
operations, and then divides the output of those operations:[{severity=$severity|count(as=_infoCount)},{count(as=_totalCount)}] |ratio:= _infoCount/_totalCount
You can also use a variable to represent a numeric value instead of a string.
-
Choose one of the following options for your query:
- Add your query to an existing panel in a dashboard.
- Create a standard or classic dashboard that includes your query.