You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add time() function to formula querying docs (#37478)
* Add time() function to formula querying docs
Add documentation for the time() function and convert the metric
arithmetic, min/max, and related subsections into collapsible blocks.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Apply suggestions from code review
Co-authored-by: Janine Chan <64388808+janine-c@users.noreply.github.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Racheal Ou <144172411+ouracheal@users.noreply.github.com>
Co-authored-by: Janine Chan <64388808+janine-c@users.noreply.github.com>
Copy file name to clipboardExpand all lines: content/en/dashboards/querying/_index.md
+20-5Lines changed: 20 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,15 +150,16 @@ Datadog also supports the ability to graph your metrics, logs, traces, and other
150
150
151
151
To graph metrics separately, use the comma (`,`). For example, `a, b, c`.
152
152
153
-
**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.
153
+
**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.
154
154
155
-
#### Metric arithmetic using an integer
155
+
{{% collapse-content title="Metric arithmetic using an integer" level="h4" %}}
156
156
157
-
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`:
157
+
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`:
158
158
159
159
{{< img src="dashboards/querying/arithmetic_4.png" alt="Formula example - multiply" style="width:75%;" >}}
160
+
{{% /collapse-content %}}
160
161
161
-
#### Arithmetic between two metrics
162
+
{{% collapse-content title="Arithmetic between two metrics" level="h4" %}}
162
163
163
164
Visualize the percentage of a metric by dividing one metric over another, for example:
164
165
@@ -181,12 +182,13 @@ status:error / status:info
181
182
{{< img src="dashboards/querying/arithmetic_6.png" alt="Formula example - logs ratio" style="width:75%;" >}}
182
183
183
184
**Note**: Formulas are not lettered. Arithmetic cannot be done between formulas.
185
+
{{% /collapse-content %}}
184
186
185
187
#### Hide a query from the visualization
186
188
187
189
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.
188
190
189
-
#### Minimum or Maximum between two queries
191
+
{{% collapse-content title="Minimum or Maximum between two queries" level="h4" %}}
190
192
191
193
Use `minimum()` and `maximum()` to compare two queries point by point and return the lower or higher value at each timestamp.
{{< 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%;" >}}
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.
217
+
218
+
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.
0 commit comments