prometheus

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright 2022 Nethermind

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.

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.

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

View Source
var (
	ErrReloadFailed   = errors.New("failed to reload Prometheus config")
	ErrInvalidOptions = errors.New("invalid options for Prometheus setup")
)

Functions

This section is empty.

Types

type AlertingConfig

type AlertingConfig struct {
	Alertmanagers []AlertmanagerConfig `yaml:"alertmanagers"`
}

AlertingConfig represents the alerting configuration for Prometheus.

type AlertmanagerConfig

type AlertmanagerConfig struct {
	StaticConfigs []StaticConfig `yaml:"static_configs"`
}

AlertmanagerConfig represents the configuration for an Alertmanager.

type Config

type Config struct {
	Global        GlobalConfig   `yaml:"global"`
	RuleFiles     []string       `yaml:"rule_files"`
	Alerting      AlertingConfig `yaml:"alerting"`
	ScrapeConfigs []ScrapeConfig `yaml:"scrape_configs"`
}

Config represents the Prometheus configuration.

type GlobalConfig

type GlobalConfig struct {
	ScrapeInterval     string `yaml:"scrape_interval"`
	EvaluationInterval string `yaml:"evaluation_interval"`
}

GlobalConfig represents the global configuration for Prometheus.

type PrometheusService

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

PrometheusService implements the ServiceAPI interface for a Prometheus service.

func NewPrometheus

func NewPrometheus() *PrometheusService

NewPrometheus creates a new PrometheusService.

func (*PrometheusService) AddTarget

func (p *PrometheusService) AddTarget(target types.MonitoringTarget, labels map[string]string, jobName string) error

AddTarget adds a new target to the Prometheus config and reloads the Prometheus configuration. Assumes endpoint is in the form http://<ip/domain>:<port>

func (*PrometheusService) ContainerName

func (p *PrometheusService) ContainerName() string

func (*PrometheusService) DotEnv

func (p *PrometheusService) DotEnv() map[string]string

DotEnv returns the dotenv variables and default values for the Prometheus service.

func (*PrometheusService) Endpoint

func (p *PrometheusService) Endpoint() string

func (*PrometheusService) Init

Init initializes the Prometheus service with the given options.

func (*PrometheusService) Name

func (p *PrometheusService) Name() string

func (*PrometheusService) RemoveTarget

func (p *PrometheusService) RemoveTarget(instanceID string) (string, error)

RemoveTarget removes a target from the Prometheus config and reloads the Prometheus configuration.

func (*PrometheusService) SetContainerIP

func (p *PrometheusService) SetContainerIP(ip net.IP)

SetContainerIP sets the container IP for the Prometheus service.

func (*PrometheusService) Setup

func (p *PrometheusService) Setup(options map[string]string) error

Setup sets up the Prometheus service configuration files with the given dotenv values.

type ScrapeConfig

type ScrapeConfig struct {
	JobName       string         `yaml:"job_name"`
	StaticConfigs []StaticConfig `yaml:"static_configs"`
	MetricsPath   string         `yaml:"metrics_path,omitempty"`
}

ScrapeConfig represents the configuration for a Prometheus scrape job.

type StaticConfig

type StaticConfig struct {
	Targets []string          `yaml:"targets"`
	Labels  map[string]string `yaml:"labels,omitempty"`
}

StaticConfig represents the static configuration for a Prometheus scrape job.

Jump to

Keyboard shortcuts

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