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.
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.
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.
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.
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.
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.
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.
Index ¶
- Constants
- Variables
- type ComposeManager
- type DockerServiceManager
- type MonitoringManager
- func (m *MonitoringManager) AddService(service ServiceAPI) error
- func (m *MonitoringManager) AddTarget(target types.MonitoringTarget, labels map[string]string, dockerNetwork string) error
- func (m *MonitoringManager) Cleanup() error
- func (m *MonitoringManager) Init() error
- func (m *MonitoringManager) InstallStack() error
- func (m *MonitoringManager) InstallationStatus() (common.Status, error)
- func (m *MonitoringManager) RemoveTarget(instanceID string) error
- func (m *MonitoringManager) Run() error
- func (m *MonitoringManager) ServiceEndpoints() map[string]string
- func (m *MonitoringManager) Status() (status common.Status, err error)
- func (m *MonitoringManager) Stop() error
- type ServiceAPI
Constants ¶
const ( PrometheusServiceName = "prometheus" PrometheusContainerName = "sedge_prometheus" GrafanaServiceName = "grafana" GrafanaContainerName = "sedge_grafana" NodeExporterServiceName = "node_exporter" NodeExporterContainerName = "sedge_node_exporter" LidoExporterServiceName = "lido_exporter" LidoExporterContainerName = "sedge_lido_exporter" InstanceIDLabel = "instance_id" SedgeNetworkName = "sedge-network" )
Variables ¶
var ( ErrInitializingMonitoringMngr = errors.New("error initializing monitoring manager") ErrCheckingMonitoringStack = errors.New("error checking monitoring stack status") ErrRunningMonitoringStack = errors.New("error running monitoring stack") ErrInstallingMonitoringMngr = errors.New("error installing monitoring manager") ErrConfiguringMonitoringServices = errors.New("error configuring monitoring services") ErrNonexistingTarget = errors.New("target to remove does not exist") )
Functions ¶
This section is empty.
Types ¶
type ComposeManager ¶
type ComposeManager interface { // Up starts the Docker Compose services defined in the Docker Compose file specified in the options. Up(opts commands.DockerComposeUpOptions) error // Down stops and removes the Docker Compose services defined in the Docker Compose file specified in the options. Down(opts commands.DockerComposeDownOptions) error // Create creates the Docker Compose services defined in the Docker Compose file specified in the options, but does not start them. Create(opts commands.DockerComposeCreateOptions) error /// PS runs the Docker Compose 'ps' command for the specified options and returns the list of services. PS(opts commands.DockerComposePsOptions) ([]compose.ComposeService, error) }
ComposeManager is an interface that defines methods for managing Docker Compose operations.
type DockerServiceManager ¶
type DockerServiceManager interface { // ContainerStatus returns the status of a container. ContainerStatus(container string) (common.Status, error) // ContainerIP returns the IP address of the container. ContainerIP(container string) (string, error) // ContainerNetworks returns the networks of a container. ContainerNetworks(container string) ([]string, error) // NetworkConnect connects a container to a network. NetworkConnect(container, network string) error // NetworkDisconnect disconnects a container from a network. NetworkDisconnect(container, network string) error }
DockerServiceManager is an interface for managing Docker containers.
type MonitoringManager ¶
type MonitoringManager struct {
// contains filtered or unexported fields
}
MonitoringManager manages the monitoring services. It provides methods for initializing the monitoring stack, adding and removing targets, running and stopping the monitoring stack, and checking the status of the monitoring stack.
func NewMonitoringManager ¶
func NewMonitoringManager( services []ServiceAPI, cmpMgr ComposeManager, dockerMgr DockerServiceManager, fs afero.Fs, locker locker.Locker, ) *MonitoringManager
NewMonitoringManager creates a new MonitoringManager with the given services, compose manager, docker manager, file system, and locker.
func (*MonitoringManager) AddService ¶
func (m *MonitoringManager) AddService(service ServiceAPI) error
AddService adds a new service to the monitoring stack dynamically.
func (*MonitoringManager) AddTarget ¶
func (m *MonitoringManager) AddTarget(target types.MonitoringTarget, labels map[string]string, dockerNetwork string) error
AddTarget adds a new target to all services in the monitoring stack. It also connects the target to the docker network of the monitoring stack if it isn't already connected. The labels are added to the service's metrics.
func (*MonitoringManager) Cleanup ¶
func (m *MonitoringManager) Cleanup() error
Cleanup removes the monitoring stack.
func (*MonitoringManager) Init ¶
func (m *MonitoringManager) Init() error
Init initializes the monitoring stack. Assumes that the stack is already installed.
func (*MonitoringManager) InstallStack ¶
func (m *MonitoringManager) InstallStack() error
InitStack initializes the monitoring stack by merging all environment variables, checking ports, setting up the stack and services, and creating containers.
func (*MonitoringManager) InstallationStatus ¶
func (m *MonitoringManager) InstallationStatus() (common.Status, error)
InstallationStatus checks whether the monitoring stack is installed and returns the installation status.
func (*MonitoringManager) RemoveTarget ¶
func (m *MonitoringManager) RemoveTarget(instanceID string) error
RemoveTarget removes a target from all services in the monitoring stack. It also disconnects the target from the docker network of the monitoring stack if it isn't already disconnected.
func (*MonitoringManager) Run ¶
func (m *MonitoringManager) Run() error
Run starts the monitoring stack by shutting down any existing stack and starting a new one.
func (*MonitoringManager) ServiceEndpoints ¶
func (m *MonitoringManager) ServiceEndpoints() map[string]string
ServiceEndpoints returns a map of the service's container names and their endpoints.
func (*MonitoringManager) Status ¶
func (m *MonitoringManager) Status() (status common.Status, err error)
Status checks the status of the containers in the monitoring stack and returns the status.
func (*MonitoringManager) Stop ¶
func (m *MonitoringManager) Stop() error
Stop shuts down the monitoring stack.
type ServiceAPI ¶
type ServiceAPI interface { // AddTarget adds a new target to the service's configuration given the endpoint of the new node. // The instanceID, network, and container name are used to identify the node as jobName in the service's configuration. // The labels are added to the service's metrics. AddTarget(target types.MonitoringTarget, labels map[string]string, jobName string) error // RemoveTarget removes a target from the service's configuration given the instanceID of the node to be removed. // It returns the network of the removed node. RemoveTarget(instanceID string) (string, error) // DotEnv returns a map of the service's environment variables and their default values. DotEnv() map[string]string // Setup configures the service given a map of options. The options should include the values for the environment variables. Setup(options map[string]string) error // Init initializes the service with the given ServiceOptions. Init(types.ServiceOptions) error // SetContainerIP sets the container IP of the service. SetContainerIP(ip net.IP) // ContainerName returns the name of the service's container. ContainerName() string // Endpoint returns the endpoint of the service. Endpoint() string // Name returns the name of the service. Name() string }
ServiceAPI defines the interface for managing a monitoring service. It provides methods for adding and removing targets, retrieving environment variables, setting up the service, and initializing the service.