You can use the metrics query builder to construct metric queries by selecting metadata fields, dimensions, metrics, and operators from pulldown lists. This makes it easier to create your search scope and to apply operators to the metrics that are returned. You’ll still want to understand the functionality of metric operators, but the metric query builder helps you by prompting you with a list of available operators, and after you choose an operator, the options or qualifiers that the operator supports.
About the UI
This section is a brief introduction to the Metric Query Builder UI. This screenshot shows the UI with a query already built.
The key components of the UI are:
- The From area is where you define the scope of your metric query, using metadata and metric dimensions. When you click in this area, you’re presented with a drop down list of the metadata fields and dimensions associated with the metrics you’ve ingested. When you select a metadata field or dimension, you’re presented with a list of values for the selected field or dimension. In our example query, we selected two dimensions,
availabilityzone. The more metadata fields and dimensions you select, the narrower your query will be.
- The get metric area is where you select the metric you want to return. When you click in this area, you’re presented with a list of metrics that match the scope you defined in the From area. In our example query, we selected the
- In this area, you can apply one or more metric operators to metric query results. When you click the plus (+) sign, you’re presented with a list of metric operators. In our example query, we selected the sum operator.
- The left pane below the query builder section presents a visualization of your query results. By default, a time series plot is presented. You can select a different visualization method, although not all visualizations make sense for every query. You can click the Preview Table to switch to a tabular view of the time series returned by your query.
- In the Visualization Type area, you can select a different visualization type: Categorical, Single Value, Map, and Honeycomb.
- The icons in the toolbar on the right side of the page allow you to customize your chart.
- The icons on the right side of the query builder area allow you to add a query, hide a query, clear a query, enter advanced mode, and duplicate a query.
Create a metric query
- In the Sumo Logic UI, click + New and choose Metrics from the drop-down list.
- The Metric Query Builder opens. Click the From field. A list of metadata fields and metric dimensions appears.
- Scroll through the list, or begin typing to dynamically narrow the list. Click a field or dimension. In the screenshot below, we clicked the
_collectormetadata field. A drop down list of values for the selected item appears.
- Scroll through the list, or begin typing to dynamically narrow the list. Click the desired value. The From field now contains the key-value pair you selected, and the metrics that match your selector are listed in the Preview Table.
- As desired, repeat the previous steps to add additional selectors to the From field.
- Click the get metric field. Scroll through the list, or begin typing to dynamically narrow the list. Select the desired metric from the list.
- The Preview Table now lists the time series that match your current query.
- At any time, you can click Chart to see a visualization of the metrics.
- The chart area now displays a visualization of the selected metric.
- To apply an operator, click the plus sign to the right of the get metric area, and select a metric from the list.
- The chart area updates to show your query results with the operator applied.
- Apply additional operators to the query, as desired.
Add another metric query
You can specify up to six queries in the Metric Query Builder.
To add an additional query
- Click the plus sign (+) to the right of the query builder area.
- A new row, labeled #B is added to the query builder area.
- Follow the steps in Create a metric query to build another query.
- Your visualization is updated to chart the additional query.
Hide a query
You can hide a query so that it is not visualized in the chart.
- Click the eye icon to the right of the query builder area in the row that contains the query you want to hide.
- The visualization for the query is hidden. Note that the query label for a hidden is faded out.
- To make the query visible, click the eye icon again.
Add a monitor to a metric query
- Select Create alert from the more options menu.
- Follow the instructions on Create a monitor and alert.
Duplicate a metric query
- Select Duplicate Query from the more options menu.
- Your query will be copied to a new row in the query builder area.
Switch to Advanced Mode
You can switch to the Metric Query Builder’s Advanced Mode if you would like to enter your query free-form, rather than using the query builder UI. To do so, select Advanced Mode from the more options menu.
Add a metric chart to a dashboard
To add a metric chart to a dashboard, click the Add to Dashboard button in the upper right corner of the Metric Query Builder.