Documentation
¶
Index ¶
- func ConvertToCheckRule(rule *PrometheusAlertingRule, groupInterval string, ruleID string) *dash0api.PrometheusAlertRule
- func ConvertToDashboard(perses *PersesDashboard) *dash0api.DashboardDefinition
- func DeeplinkURL(apiUrl, assetType, assetID string) string
- func DetectKind(data []byte) string
- func ExtractCheckRuleID(rule *dash0api.PrometheusAlertRule) string
- func ExtractCheckRuleName(rule *dash0api.PrometheusAlertRule) string
- func ExtractDashboardDisplayName(dashboard *dash0api.DashboardDefinition) string
- func ExtractDashboardID(dashboard *dash0api.DashboardDefinition) string
- func ExtractPersesDashboardID(perses *PersesDashboard) string
- func ExtractPersesDashboardName(perses *PersesDashboard) string
- func ExtractPrometheusRuleID(rule *PrometheusRule) string
- func ExtractPrometheusRuleName(rule *PrometheusRule) string
- func ExtractSyntheticCheckID(check *dash0api.SyntheticCheckDefinition) string
- func ExtractSyntheticCheckName(check *dash0api.SyntheticCheckDefinition) string
- func ExtractViewID(view *dash0api.ViewDefinition) string
- func ExtractViewName(view *dash0api.ViewDefinition) string
- func KindDisplayName(kind string) string
- func LogsExplorerURL(apiUrl string, filters []DeeplinkFilter, from, to string, dataset *string) string
- func ReadDefinition(path string, target interface{}, stdin io.Reader) error
- func ReadDefinitionFile(path string, target interface{}) error
- func ReadRawInput(path string, stdin io.Reader) ([]byte, error)
- func RegisterCommonFlags(cmd *cobra.Command, flags *CommonFlags)
- func RegisterDeleteFlags(cmd *cobra.Command, flags *DeleteFlags)
- func RegisterFileInputFlags(cmd *cobra.Command, flags *FileInputFlags)
- func RegisterGetFlags(cmd *cobra.Command, flags *GetFlags)
- func RegisterListFlags(cmd *cobra.Command, flags *ListFlags)
- func SpansExplorerURL(apiUrl string, filters []DeeplinkFilter, from, to string, dataset *string) string
- func TracesExplorerURL(apiUrl, traceID string, dataset *string) string
- func ViewDeeplinkURL(apiUrl, viewType, assetID string) string
- func WriteDefinitionFile(path string, data interface{}) error
- func WriteToStdout(format string, data interface{}) error
- type CommonFlags
- type DeeplinkFilter
- type DeleteFlags
- type FileInputFlags
- type GetFlags
- type ImportAction
- type ImportResult
- func ImportCheckRule(ctx context.Context, apiClient dash0api.Client, ...) (ImportResult, error)
- func ImportDashboard(ctx context.Context, apiClient dash0api.Client, ...) (ImportResult, error)
- func ImportPersesDashboard(ctx context.Context, apiClient dash0api.Client, perses *PersesDashboard, ...) (ImportResult, error)
- func ImportPrometheusRule(ctx context.Context, apiClient dash0api.Client, promRule *PrometheusRule, ...) ([]ImportResult, error)
- func ImportSyntheticCheck(ctx context.Context, apiClient dash0api.Client, ...) (ImportResult, error)
- func ImportView(ctx context.Context, apiClient dash0api.Client, view *dash0api.ViewDefinition, ...) (ImportResult, error)
- type ListFlags
- type PersesDashboard
- type PersesDashboardMetadata
- type PrometheusAlertingRule
- type PrometheusRule
- type PrometheusRuleGroup
- type PrometheusRuleMetadata
- type PrometheusRuleSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToCheckRule ¶ added in v1.1.0
func ConvertToCheckRule(rule *PrometheusAlertingRule, groupInterval string, ruleID string) *dash0api.PrometheusAlertRule
ConvertToCheckRule converts a Prometheus alerting rule to a Dash0 CheckRule
func ConvertToDashboard ¶ added in v1.6.0
func ConvertToDashboard(perses *PersesDashboard) *dash0api.DashboardDefinition
ConvertToDashboard converts a PersesDashboard CRD into a Dash0 DashboardDefinition. It normalizes v1alpha1/v1alpha2 differences (the v1alpha2 CRD wraps the spec in a "config" key) and ensures a display name is set, falling back to metadata.name.
func DeeplinkURL ¶ added in v1.2.0
DeeplinkURL constructs a deeplink URL for the given asset type and ID. The base URL is derived from the API URL by extracting the domain suffix (e.g. "dash0.com" from "api.us-west-2.aws.dash0.com") and prepending "app.". Returns an empty string if the API URL is empty or cannot be parsed.
func DetectKind ¶ added in v1.1.0
DetectKind extracts the "kind" field from raw YAML/JSON bytes. When the document has no explicit "kind" (e.g. a check rule exported via `check-rules get -o yaml`), the kind is inferred from the document structure: the "expression" field is required for check rules and absent in all other asset types.
func ExtractCheckRuleID ¶ added in v1.5.3
func ExtractCheckRuleID(rule *dash0api.PrometheusAlertRule) string
ExtractCheckRuleID extracts the ID from a check rule definition.
func ExtractCheckRuleName ¶ added in v1.5.3
func ExtractCheckRuleName(rule *dash0api.PrometheusAlertRule) string
ExtractCheckRuleName extracts the name from a check rule definition.
func ExtractDashboardDisplayName ¶ added in v1.1.0
func ExtractDashboardDisplayName(dashboard *dash0api.DashboardDefinition) string
ExtractDashboardDisplayName extracts the display name from a dashboard definition.
func ExtractDashboardID ¶ added in v1.5.3
func ExtractDashboardID(dashboard *dash0api.DashboardDefinition) string
ExtractDashboardID extracts the ID from a dashboard definition.
func ExtractPersesDashboardID ¶ added in v1.6.0
func ExtractPersesDashboardID(perses *PersesDashboard) string
ExtractPersesDashboardID returns the dash0.com/id label value if present.
func ExtractPersesDashboardName ¶ added in v1.6.0
func ExtractPersesDashboardName(perses *PersesDashboard) string
ExtractPersesDashboardName returns the display name from the Perses spec, falling back to metadata.name.
func ExtractPrometheusRuleID ¶ added in v1.5.3
func ExtractPrometheusRuleID(rule *PrometheusRule) string
ExtractPrometheusRuleID extracts the ID from a PrometheusRule definition.
func ExtractPrometheusRuleName ¶ added in v1.5.3
func ExtractPrometheusRuleName(rule *PrometheusRule) string
ExtractPrometheusRuleName extracts the name from a PrometheusRule definition.
func ExtractSyntheticCheckID ¶ added in v1.5.3
func ExtractSyntheticCheckID(check *dash0api.SyntheticCheckDefinition) string
ExtractSyntheticCheckID extracts the ID from a synthetic check definition.
func ExtractSyntheticCheckName ¶ added in v1.5.3
func ExtractSyntheticCheckName(check *dash0api.SyntheticCheckDefinition) string
ExtractSyntheticCheckName extracts the display name from a synthetic check definition, falling back to metadata.name if no display name is set.
func ExtractViewID ¶ added in v1.5.3
func ExtractViewID(view *dash0api.ViewDefinition) string
ExtractViewID extracts the ID from a view definition.
func ExtractViewName ¶ added in v1.5.3
func ExtractViewName(view *dash0api.ViewDefinition) string
ExtractViewName extracts the display name from a view definition, falling back to metadata.name if the display name is empty.
func KindDisplayName ¶ added in v1.1.0
KindDisplayName returns the human-readable name for an asset kind. Multi-word kinds like "CheckRule" become "Check rule" and "SyntheticCheck" becomes "Synthetic check".
func LogsExplorerURL ¶ added in v1.5.4
func LogsExplorerURL(apiUrl string, filters []DeeplinkFilter, from, to string, dataset *string) string
LogsExplorerURL builds a deep link URL to the Dash0 logs explorer. The URL includes filter criteria, time range, and optional dataset as query parameters. Returns an empty string if the API URL is empty or cannot be parsed.
func ReadDefinition ¶
ReadDefinition reads a YAML or JSON definition from a file or stdin. If path is "-" or empty, it reads from stdin (assumes YAML format). Otherwise, it reads from the file at the given path.
func ReadDefinitionFile ¶
ReadDefinitionFile reads a YAML or JSON file and unmarshals into the target. It auto-detects the format based on file extension, falling back to YAML first.
func ReadRawInput ¶ added in v1.1.0
ReadRawInput reads raw bytes from a file or stdin without unmarshalling. If path is "-" or empty, it reads from stdin.
func RegisterCommonFlags ¶
func RegisterCommonFlags(cmd *cobra.Command, flags *CommonFlags)
RegisterCommonFlags adds common flags to a command
func RegisterDeleteFlags ¶
func RegisterDeleteFlags(cmd *cobra.Command, flags *DeleteFlags)
RegisterDeleteFlags adds delete-specific flags to a command
func RegisterFileInputFlags ¶
func RegisterFileInputFlags(cmd *cobra.Command, flags *FileInputFlags)
RegisterFileInputFlags adds file input flags to a command and marks -f as required
func RegisterGetFlags ¶
RegisterGetFlags adds get-specific flags to a command
func RegisterListFlags ¶
RegisterListFlags adds list-specific flags to a command
func SpansExplorerURL ¶ added in v1.5.4
func SpansExplorerURL(apiUrl string, filters []DeeplinkFilter, from, to string, dataset *string) string
SpansExplorerURL builds a deep link URL to the Dash0 traces explorer. The URL includes optional filter criteria, time range, and optional dataset as query parameters. Returns an empty string if the API URL is empty or cannot be parsed.
func TracesExplorerURL ¶ added in v1.5.4
TracesExplorerURL builds a deep link URL to the Dash0 traces explorer for a specific trace. The URL includes the trace ID and optional dataset as query parameters. Returns an empty string if the API URL is empty or cannot be parsed.
func ViewDeeplinkURL ¶ added in v1.5.1
ViewDeeplinkURL constructs a deeplink URL for a view, using the view's type to determine the correct path (e.g. /goto/spans for span views, /goto/logs for log views). Returns an empty string if the API URL is empty, cannot be parsed, or the view type is unknown.
func WriteDefinitionFile ¶
WriteDefinitionFile writes data to a YAML or JSON file. It auto-detects the format based on file extension, defaulting to YAML.
func WriteToStdout ¶
WriteToStdout writes data to stdout in the specified format. Format can be "yaml", "yml", or "json".
Types ¶
type CommonFlags ¶
CommonFlags holds common flag values used across all asset commands
type DeeplinkFilter ¶ added in v1.5.4
type DeeplinkFilter struct {
Key string `json:"key"`
Operator string `json:"operator"`
Value string `json:"value,omitempty"`
}
DeeplinkFilter represents a single filter criterion for explorer deep links.
func FiltersToDeeplinkFilters ¶ added in v1.5.4
func FiltersToDeeplinkFilters(filters *dash0api.FilterCriteria) []DeeplinkFilter
FiltersToDeeplinkFilters converts parsed API filter criteria to deep link filter objects suitable for URL serialization.
type DeleteFlags ¶
type DeleteFlags struct {
CommonFlags
Force bool
}
DeleteFlags holds flags specific to delete commands
type FileInputFlags ¶
type FileInputFlags struct {
CommonFlags
File string
DryRun bool
}
FileInputFlags holds flags for file-based input operations (create, update, apply)
type ImportAction ¶ added in v1.1.0
type ImportAction string
ImportAction indicates whether an asset was created or updated.
const ( ActionCreated ImportAction = "created" ActionUpdated ImportAction = "updated" )
type ImportResult ¶ added in v1.1.0
type ImportResult struct {
Name string
ID string
Action ImportAction
}
ImportResult holds the outcome of importing an asset.
func ImportCheckRule ¶ added in v1.1.0
func ImportCheckRule(ctx context.Context, apiClient dash0api.Client, rule *dash0api.PrometheusAlertRule, dataset *string) (ImportResult, error)
ImportCheckRule checks existence by rule ID, strips the ID when the asset is not found, and calls the import API.
func ImportDashboard ¶ added in v1.1.0
func ImportDashboard(ctx context.Context, apiClient dash0api.Client, dashboard *dash0api.DashboardDefinition, dataset *string) (ImportResult, error)
ImportDashboard checks existence by dash0Extensions.id, strips server-generated fields when the asset is not found, and calls the import API. The import API uses dash0Extensions.id as the upsert key; when the input has no id, a fresh UUID is generated so re-applying the exported YAML updates the dashboard instead of creating a duplicate.
func ImportPersesDashboard ¶ added in v1.6.0
func ImportPersesDashboard(ctx context.Context, apiClient dash0api.Client, perses *PersesDashboard, dataset *string) (ImportResult, error)
ImportPersesDashboard converts a PersesDashboard CRD to a Dash0 dashboard and imports it. It returns the import result (created or updated).
func ImportPrometheusRule ¶ added in v1.1.0
func ImportPrometheusRule(ctx context.Context, apiClient dash0api.Client, promRule *PrometheusRule, dataset *string) ([]ImportResult, error)
ImportPrometheusRule extracts alerting rules from a PrometheusRule CRD, converts each to a Dash0 CheckRule, and imports them. Returns one result per rule. On partial failure, returns the successfully imported results along with the error.
func ImportSyntheticCheck ¶ added in v1.1.0
func ImportSyntheticCheck(ctx context.Context, apiClient dash0api.Client, check *dash0api.SyntheticCheckDefinition, dataset *string) (ImportResult, error)
ImportSyntheticCheck checks existence by Dash0Comid, strips server-generated fields, and calls the import API.
func ImportView ¶ added in v1.1.0
func ImportView(ctx context.Context, apiClient dash0api.Client, view *dash0api.ViewDefinition, dataset *string) (ImportResult, error)
ImportView checks existence by Dash0Comid, strips server-generated fields, and calls the import API.
type ListFlags ¶
type ListFlags struct {
CommonFlags
Limit int
All bool
SkipHeader bool
}
ListFlags holds flags specific to list commands
type PersesDashboard ¶ added in v1.6.0
type PersesDashboard struct {
APIVersion string `yaml:"apiVersion" json:"apiVersion"`
Kind string `yaml:"kind" json:"kind"`
Metadata PersesDashboardMetadata `yaml:"metadata" json:"metadata"`
Spec map[string]interface{} `yaml:"spec" json:"spec"`
}
PersesDashboard represents the Perses Operator PersesDashboard CRD (perses.dev/v1alpha1 and perses.dev/v1alpha2).
type PersesDashboardMetadata ¶ added in v1.6.0
type PersesDashboardMetadata struct {
Name string `yaml:"name,omitempty" json:"name,omitempty"`
Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`
Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
Annotations map[string]string `yaml:"annotations,omitempty" json:"annotations,omitempty"`
}
PersesDashboardMetadata contains metadata for a PersesDashboard.
type PrometheusAlertingRule ¶ added in v1.1.0
type PrometheusAlertingRule struct {
Alert string `yaml:"alert,omitempty" json:"alert,omitempty"`
Expr string `yaml:"expr" json:"expr"`
For string `yaml:"for,omitempty" json:"for,omitempty"`
Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
Annotations map[string]string `yaml:"annotations,omitempty" json:"annotations,omitempty"`
}
PrometheusAlertingRule represents an individual alerting rule within a group
type PrometheusRule ¶ added in v1.1.0
type PrometheusRule struct {
APIVersion string `yaml:"apiVersion" json:"apiVersion"`
Kind string `yaml:"kind" json:"kind"`
Metadata PrometheusRuleMetadata `yaml:"metadata" json:"metadata"`
Spec PrometheusRuleSpec `yaml:"spec" json:"spec"`
}
PrometheusRule represents the Prometheus Operator PrometheusRule CRD
type PrometheusRuleGroup ¶ added in v1.1.0
type PrometheusRuleGroup struct {
Name string `yaml:"name" json:"name"`
Interval string `yaml:"interval,omitempty" json:"interval,omitempty"`
Rules []PrometheusAlertingRule `yaml:"rules" json:"rules"`
}
PrometheusRuleGroup represents a group of alerting rules
type PrometheusRuleMetadata ¶ added in v1.1.0
type PrometheusRuleMetadata struct {
Name string `yaml:"name,omitempty" json:"name,omitempty"`
Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`
Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
Annotations map[string]string `yaml:"annotations,omitempty" json:"annotations,omitempty"`
}
PrometheusRuleMetadata contains metadata for a PrometheusRule
type PrometheusRuleSpec ¶ added in v1.1.0
type PrometheusRuleSpec struct {
Groups []PrometheusRuleGroup `yaml:"groups" json:"groups"`
}
PrometheusRuleSpec contains the spec for a PrometheusRule