render

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DatadogTemplateFuncs = template.FuncMap{
	"ddDateTime": func(t time.Time) string {
		return t.Format(time.RFC3339)
	},
	"ddStringIn": func(values []string) string {
		if len(values) == 0 {
			return ""
		}
		quoted := make([]string, len(values))
		for i, v := range values {

			escaped := strings.ReplaceAll(v, `"`, `\"`)
			quoted[i] = `"` + escaped + `"`
		}
		return strings.Join(quoted, ",")
	},
	"ddLike": func(pattern string) string {

		escaped := strings.ReplaceAll(pattern, `"`, `\"`)
		return `"` + escaped + `"`
	},
	"ddFacet": func(field string) string {

		if !strings.HasPrefix(field, "@") && !strings.Contains(field, ".") {
			return "@" + field
		}
		return field
	},
}

DatadogTemplateFuncs provides template helpers for Datadog search queries

Functions

func RenderDatadogQuery

func RenderDatadogQuery(ctx context.Context, tmpl string, params map[string]interface{}) (types.DatadogQuery, error)

RenderDatadogQuery renders a query template with the given parameters

func ValidateQuery

func ValidateQuery(query string) error

ValidateQuery performs basic validation on the rendered query

Types

This section is empty.

Jump to

Keyboard shortcuts

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