utils

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildMatchers

func BuildMatchers(alertEvent *model.MonitorAlertEvent, l *zap.Logger, useName int8) ([]*labels.Matcher, error)

func CalculateAlertHash

func CalculateAlertHash(pool *model.MonitorAlertManagerPool) string

func CalculatePromHash

func CalculatePromHash(pool *model.MonitorScrapePool) string

CalculatePromHash 计算哈希值(不修改入参数据)

func CloneMap

func CloneMap(original map[string]string) map[string]string

CloneMap 克隆一个字符串到字符串的映射

func CopyMap

func CopyMap[K comparable, V any](src map[K]V) map[K]V

CopyMap 深拷贝一个 map

func DeepCopyScrapeConfig

func DeepCopyScrapeConfig(sc *pc.ScrapeConfig) *pc.ScrapeConfig

DeepCopyScrapeConfig 深度拷贝 ScrapeConfig

func FormatMap

func FormatMap(m map[string]string) string

FormatMap 将 map[string]string 格式化为字符串,每个键值对占一行

func FromSliceTuMap

func FromSliceTuMap(kvs []string) map[string]string

func GenPromDuration

func GenPromDuration(seconds int) promModel.Duration

GenPromDuration 转换秒为Prometheus Duration

func ParseExternalLabels

func ParseExternalLabels(labelsList []string) []string

ParseExternalLabels 解析外部标签

func ParseTags

func ParseTags(tags []string) (map[promModel.LabelName]promModel.LabelValue, error)

ParseTags 将 ECS 的 Tags 切片解析为 Prometheus 的标签映射

func ParseURL

func ParseURL(u string) (*pcc.URL, error)

ParseURL 解析字符串为URL,返回错误而非 panic

func PostWithJson

func PostWithJson(ctx context.Context, client *http.Client, l *zap.Logger, url string, jsonStr string, params map[string]string, headers map[string]string) ([]byte, error)

PostWithJson 发送带有JSON字符串的POST请求

func PromqlExprCheck

func PromqlExprCheck(expr string) (bool, error)

func ValidateScrapeTiming

func ValidateScrapeTiming(interval, timeout int) error

ValidateScrapeTiming 校验采集间隔与超时时间

Types

This section is empty.

Jump to

Keyboard shortcuts

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