internal

package
v0.0.0-...-e001e23 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Copyright 2025 Microsoft Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CliConfig

type CliConfig struct {
	PrometheusRules            PrometheusRulesConfig            `json:"prometheusRules"`
	InternalSubscriptionFilter InternalSubscriptionFilterConfig `json:"internalSubscriptionFilter,omitempty"`
}

type CorrelationIDSegment

type CorrelationIDSegment struct {
	Type  string `json:"type"`
	Value string `json:"value,omitempty"`
	Name  string `json:"name,omitempty"`
}

CorrelationIDSegment is a single segment of a parsed correlation ID. Each segment is either a literal string value or a reference to a Prometheus label.

type CorrelationMapEntry

type CorrelationMapEntry struct {
	Alert    string                 `json:"alert"`
	Segments []CorrelationIDSegment `json:"correlationId"`
}

CorrelationMapEntry holds the mapping between a monitor identifier and its parsed correlation ID segments.

type GroupAlerts

type GroupAlerts struct {
	GroupName  string   `json:"groupName"`
	Alerts     []string `json:"alerts"`
	Namespaces []string `json:"namespaces,omitempty"`
}

type InternalSubscriptionFilterConfig

type InternalSubscriptionFilterConfig struct {
	Enabled bool   `json:"enabled,omitempty"`
	Table   string `json:"table,omitempty"`
}

InternalSubscriptionFilterConfig configures post-expression filtering of internal (e2e/dev/test) subscriptions. When enabled, alerts that carry the label exclude_internal_subscriptions: "true" have their PromQL expression wrapped with an `unless on(subscription_id) <Table>` clause. The recording rule referenced by Table must exist in the Azure Monitor Workspace; if it does not, the unless is a no-op (empty set excludes nothing).

type Options

type Options struct {
	// contains filtered or unexported fields
}

func NewOptions

func NewOptions() *Options

func (*Options) Complete

func (o *Options) Complete(configFilePath string, promtoolPath string) error

func (*Options) CorrelationMap

func (o *Options) CorrelationMap() ([]CorrelationMapEntry, error)

CorrelationMap iterates all alerting rules (using the same logic as Generate) and returns the mapping between group/alert names and their parsed correlation ID segments.

func (*Options) Generate

func (o *Options) Generate() error

func (*Options) RunTests

func (o *Options) RunTests() error

func (*Options) WithPreserveAggregationLabels

func (o *Options) WithPreserveAggregationLabels(labels []string) *Options

WithPreserveAggregationLabels configures the labels that must be preserved through every aggregation when generating rules.

type PrometheusRulesConfig

type PrometheusRulesConfig struct {
	RulesFolders              []string       `json:"rulesFolders"`
	UntestedRules             []string       `json:"untestedRules,omitempty"`
	TestDependencies          []string       `json:"testDependencies,omitempty"`
	OutputBicep               string         `json:"outputBicep"`
	IncludedAlertsByGroup     []GroupAlerts  `json:"includedAlertsByGroup,omitempty"` // Optional: Only alerts listed here are included; if empty, all alerts are included
	LabelsToExtract           []string       `json:"labelsToExtract,omitempty"`
	OutputReplacements        []Replacements `json:"outputReplacements,omitempty"`
	RegexOutputReplacements   []Replacements `json:"regexOutputReplacements,omitempty"`
	DefaultEvaluationInterval string         `json:"defaultEvaluationInterval,omitempty"`
	GroupNamePrefix           string         `json:"groupNamePrefix,omitempty"`
}

type RegexReplacements

type RegexReplacements struct {
	From *regexp.Regexp
	To   string
}

type ReplacementWriter

type ReplacementWriter struct {
	// contains filtered or unexported fields
}

func NewReplacementWriter

func NewReplacementWriter(w io.Writer, replacements []Replacements, regexReplacements []RegexReplacements) *ReplacementWriter

func (*ReplacementWriter) Write

func (rw *ReplacementWriter) Write(p []byte) (n int, err error)

type Replacements

type Replacements struct {
	From string `json:"from"`
	To   string `json:"to"`
}

Jump to

Keyboard shortcuts

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