Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions content/en/dashboards/querying/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,14 @@

**Note**: Queries using commas are only supported in visualizations, they do not work on monitors. Use [boolean operators][15] or arithmetic operations to combine multiple metrics in a monitor.

#### Metric arithmetic using an integer
{{% collapse-content title="Metric arithmetic using an integer" level="h5" %}}

Modify the displayed value of a metric on a graph by performing an arithmetic operation. For example, to visualize the double of a specific metric, click the {{< ui >}}Advanced...{{< /ui >}} link in the graph editor. Then enter your arithmetic in the `Formula` box, in this case: `a * 2`:

{{< img src="dashboards/querying/arithmetic_4.png" alt="Formula example - multiply" style="width:75%;" >}}
{{% /collapse-content %}}

#### Arithmetic between two metrics
{{% collapse-content title="Arithmetic between two metrics" level="h5" %}}

Visualize the percentage of a metric by dividing one metric over another, for example:

Expand All @@ -181,12 +182,13 @@
{{< img src="dashboards/querying/arithmetic_6.png" alt="Formula example - logs ratio" style="width:75%;" >}}

**Note**: Formulas are not lettered. Arithmetic cannot be done between formulas.
{{% /collapse-content %}}

#### Hide a query from the visualization

When a widget has multiple queries and a formula, you can hide individual queries so only the formula result appears on the graph. Click the query's letter label to toggle its visibility on the graph. A blue label indicates the query is displayed; a grey label indicates it is hidden. The hidden query is still used in the formula calculation.

#### Minimum or Maximum between two queries
{{% collapse-content title="Minimum or Maximum between two queries" level="h5" %}}

Use `minimum()` and `maximum()` to compare two queries point by point and return the lower or higher value at each timestamp.

Expand All @@ -207,6 +209,19 @@
```

{{< img src="dashboards/querying/minmax_logs_platform_example.png" alt="Formula example for 'minimum' showing the lower value between two log queries" style="width:75%;" >}}
{{% /collapse-content %}}

{{% collapse-content title="time() function" level="h5" %}}

The `time()` function returns the current Unix time in seconds as a timeseries. Use it in formulas to compare a metric's timestamp against the present, which helps monitor data freshness or calculate time until an expiration.

Check warning on line 216 in content/en/dashboards/querying/_index.md

View workflow job for this annotation

GitHub Actions / vale

Datadog.words_case_sensitive

Use 'UNIX' instead of 'Unix'.

For example, to calculate the time elapsed in seconds since the last reported backup, you can use `time()` to find the difference between the present and the timestamp of the backup metric.

Check notice on line 218 in content/en/dashboards/querying/_index.md

View workflow job for this annotation

GitHub Actions / vale

Datadog.sentencelength

Suggestion: Try to keep your sentence length to 25 words or fewer.

```text
time() - max:backup.last_completed_timestamp{*}
```

{{% /collapse-content %}}

### Create an alias

Expand Down
Loading