datadog

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryAndValidateMetrics

func QueryAndValidateMetrics(query string, validate func(datadogV1.MetricsQueryMetadata) error) error

QueryAndValidateMetrics queries metrics from Datadog.

query can be a query string like the following examples: - "avg:kubernetes.cpu.user.total{*}" - "system.cpu.idle{*}"

Note that this function does not validate the query on its own. For example, the following query is invalid:

"avg:kubernetes.cpu.user.total"

You get:

Error parsing query: \nunable to parse avg:kubernetes.cpu.user.total: Rule 'scope_expr' didn't match at ” (line 1, column 30).

because it lacks the scope_expr, which is required for the query to be valid. This specific query should be:

"avg:kubernetes.cpu.user.total{*}"

The validate function is called for each series in the response. You can use this function to validate the metadata of the series. The whole QueryAndValidateMetrics function returns an error if any of the validate calls return an error.

func RequireMetrics

func RequireMetrics(t *testing.T, query string, validate func(datadogV1.MetricsQueryMetadata) error)

RequireMetrics queries metrics from Datadog and validates them.

query can be a query string like the following examples: - "avg:kubernetes.cpu.user.total{*}" - "system.cpu.idle{*}"

Note that this function does not validate the query on its own. For example, the following query is invalid:

"avg:kubernetes.cpu.user.total"

You get:

Error parsing query: \nunable to parse avg:kubernetes.cpu.user.total: Rule 'scope_expr' didn't match at ” (line 1, column 30).

because it lacks the scope_expr, which is required for the query to be valid. This specific query should be:

"avg:kubernetes.cpu.user.total{*}"

The test fails if the query returns no series, or if any of the validate calls return an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL