metrics

package
v0.0.0-...-a841328 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: MIT Imports: 25 Imported by: 1

Documentation

Index

Constants

View Source
const (
	AzureMetricApiMaxMetricNumber = 20
)
View Source
const (
	MetricHelpDefault = "Azure monitor insight metric"
)
View Source
const (
	PrometheusMetricNameDefault = "azurerm_resource_metric"
)
View Source
const (
	ResourceGraphQueryTop = 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureInsightBaseMetricsResult

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

type AzureInsightMetricsResult

type AzureInsightMetricsResult struct {
	AzureInsightBaseMetricsResult

	Result *armmonitor.MetricsClientListResponse
	// contains filtered or unexported fields
}

func (*AzureInsightMetricsResult) SendMetricToChannel

func (r *AzureInsightMetricsResult) SendMetricToChannel(channel chan<- PrometheusMetricResult)

type AzureInsightSubscriptionMetricsResult

type AzureInsightSubscriptionMetricsResult struct {
	AzureInsightBaseMetricsResult

	Result *armmonitor.MetricsClientListAtSubscriptionScopeResponse
	// contains filtered or unexported fields
}

func (*AzureInsightSubscriptionMetricsResult) SendMetricToChannel

func (r *AzureInsightSubscriptionMetricsResult) SendMetricToChannel(channel chan<- PrometheusMetricResult)

type AzureResource

type AzureResource struct {
	ID       string
	Location string
	Tags     map[string]string
}

type AzureServiceDiscovery

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

func (*AzureServiceDiscovery) FindResourceGraph

func (sd *AzureServiceDiscovery) FindResourceGraph(ctx context.Context, subscriptions []string, resourceType, filter string) error

func (*AzureServiceDiscovery) FindSubscriptionResources

func (sd *AzureServiceDiscovery) FindSubscriptionResources(subscriptionId, filter string)

func (*AzureServiceDiscovery) FindSubscriptionResourcesWithScrapeTags

func (sd *AzureServiceDiscovery) FindSubscriptionResourcesWithScrapeTags(ctx context.Context, subscriptionId, filter, metricTagName, aggregationTagName string)

func (*AzureServiceDiscovery) ResourcesClient

func (sd *AzureServiceDiscovery) ResourcesClient(subscriptionId string) (*armresources.Client, error)

type MetricList

type MetricList struct {
	List map[string][]MetricRow
	Help map[string]string
}

func NewMetricList

func NewMetricList() *MetricList

func (*MetricList) Add

func (l *MetricList) Add(name string, metric ...MetricRow)

func (*MetricList) GetMetricHelp

func (l *MetricList) GetMetricHelp(name string) string

func (*MetricList) GetMetricLabelNames

func (l *MetricList) GetMetricLabelNames(name string) []string

func (*MetricList) GetMetricList

func (l *MetricList) GetMetricList(name string) []MetricRow

func (*MetricList) GetMetricNames

func (l *MetricList) GetMetricNames() (list []string)

func (*MetricList) SetMetricHelp

func (l *MetricList) SetMetricHelp(name, help string)

type MetricProbeTarget

type MetricProbeTarget struct {
	ResourceId   string
	Metrics      []string
	Aggregations []string
	Tags         map[string]string
}

type MetricProber

type MetricProber struct {
	Conf config.Opts

	AzureClient             *armclient.ArmClient
	AzureResourceTagManager *armclient.ResourceTagManager

	ServiceDiscovery AzureServiceDiscovery
	// contains filtered or unexported fields
}

func NewMetricProber

func NewMetricProber(ctx context.Context, logger *zap.SugaredLogger, w http.ResponseWriter, settings *RequestMetricSettings, conf config.Opts) *MetricProber

func (*MetricProber) AddTarget

func (p *MetricProber) AddTarget(targets ...MetricProbeTarget)

func (*MetricProber) EnableMetricsCache

func (p *MetricProber) EnableMetricsCache(cache *cache.Cache, cacheKey string, cacheDuration *time.Duration)

func (*MetricProber) EnableServiceDiscoveryCache

func (p *MetricProber) EnableServiceDiscoveryCache(cache *cache.Cache, cacheDuration *time.Duration)

func (*MetricProber) FetchFromCache

func (p *MetricProber) FetchFromCache() bool

func (*MetricProber) FetchMetricsFromTarget

func (p *MetricProber) FetchMetricsFromTarget(client *armmonitor.MetricsClient, target MetricProbeTarget, metrics, aggregations []string) (AzureInsightMetricsResult, error)

func (*MetricProber) Init

func (p *MetricProber) Init()

func (*MetricProber) MetricsClient

func (p *MetricProber) MetricsClient(subscriptionId string) (*armmonitor.MetricsClient, error)

func (*MetricProber) RegisterSubscriptionCollectFinishCallback

func (p *MetricProber) RegisterSubscriptionCollectFinishCallback(callback func(subscriptionId string))

func (*MetricProber) Run

func (p *MetricProber) Run()

func (*MetricProber) RunOnSubscriptionScope

func (p *MetricProber) RunOnSubscriptionScope()

func (*MetricProber) SaveToCache

func (p *MetricProber) SaveToCache()

func (*MetricProber) SetAzureClient

func (p *MetricProber) SetAzureClient(client *armclient.ArmClient)

func (*MetricProber) SetAzureResourceTagManager

func (p *MetricProber) SetAzureResourceTagManager(client *armclient.ResourceTagManager)

func (*MetricProber) SetPrometheusRegistry

func (p *MetricProber) SetPrometheusRegistry(registry *prometheus.Registry)

func (*MetricProber) SetUserAgent

func (p *MetricProber) SetUserAgent(value string)

type MetricRow

type MetricRow struct {
	Labels prometheus.Labels
	Value  float64
}

type PrometheusMetricResult

type PrometheusMetricResult struct {
	Name   string
	Labels prometheus.Labels
	Value  float64
	Help   string
}

type RequestMetricSettings

type RequestMetricSettings struct {
	Name            string
	Subscriptions   []string
	ResourceType    string
	Filter          string
	Timespan        string
	Interval        *string
	Metrics         []string
	MetricNamespace string
	Aggregations    []string
	Regions         []string

	// needed for dimension support
	MetricTop     *int32
	MetricFilter  string
	MetricOrderBy string

	ValidateDimensions bool

	MetricTemplate string
	HelpTemplate   string

	DimensionLowercase bool

	// cache
	Cache *time.Duration
}

func NewRequestMetricSettings

func NewRequestMetricSettings(r *http.Request, opts config.Opts) (RequestMetricSettings, error)

func NewRequestMetricSettingsForAzureResourceApi

func NewRequestMetricSettingsForAzureResourceApi(r *http.Request, opts config.Opts) (RequestMetricSettings, error)

func (*RequestMetricSettings) CacheDuration

func (s *RequestMetricSettings) CacheDuration(requestTime time.Time) (ret *time.Duration)

func (*RequestMetricSettings) SetAggregations

func (s *RequestMetricSettings) SetAggregations(val string)

func (*RequestMetricSettings) SetMetrics

func (s *RequestMetricSettings) SetMetrics(val string)

Jump to

Keyboard shortcuts

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