mongodbreceiver

package module
v0.71.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: Apache-2.0 Imports: 23 Imported by: 8

README

MongoDB Receiver

Status
Stability beta
Supported pipeline types metrics
Distributions contrib

This receiver fetches stats from a MongoDB instance using the golang mongo driver. Stats are collected via MongoDB's dbStats and serverStatus commands.

Purpose

The purpose of this receiver is to allow users to monitor metrics from standalone MongoDB clusters. This includes non-Atlas managed MongoDB Servers.

Prerequisites

This receiver supports MongoDB versions:

  • 4.0+
  • 5.0

Mongodb recommends to set up a least privilege user (LPU) with a clusterMonitor role in order to collect metrics. Please refer to lpu.sh for an example of how to configure these permissions.

Configuration

The following settings are optional:

  • hosts (default: [localhost:27017]): list of host:port or unix domain socket endpoints.
    • For standalone MongoDB deployments this is the hostname and port of the mongod instance
    • For replica sets specify the hostnames and ports of the mongod instances that are in the replica set configuration. If the replica_set field is specified, nodes will be autodiscovered.
    • For a sharded MongoDB deployment, please specify a list of the mongos hosts.
  • username: If authentication is required, the user can with clusterMonitor permissions can be provided here.
  • password: If authentication is required, the password can be provided here.
  • collection_interval: (default = 1m): This receiver collects metrics on an interval. This value must be a string readable by Golang's time.ParseDuration. Valid time units are ns, us (or µs), ms, s, m, h.
  • replica_set: If the deployment of MongoDB is a replica set then this allows users to specify the replica set name which allows for autodiscovery of other nodes in the replica set.
  • timeout: (default = 1m) The timeout of running commands against mongo.
  • tls: (defaults defined here): TLS control. By default insecure settings are rejected and certificate verification is on.
Example Configuration
receivers:
  mongodb:
    hosts:
      - endpoint: localhost:27017
    username: otel
    password: ${env:MONGODB_PASSWORD}
    collection_interval: 60s
    tls:
      insecure: true
      insecure_skip_verify: true

The full list of settings exposed for this receiver are documented here with detailed sample configurations here.

Metrics

The following metric are available with versions:

  • mongodb.extent.count < 4.4 with mmapv1 storage engine
  • mongodb.session.count >= 3.0 with wiredTiger storage engine
  • mongodb.cache.operations >= 3.0 with wiredTiger storage engine
  • mongodb.connection.count with attribute active is available >= 4.0
  • mongodb.index.access.count >= 4.0

Details about the metrics produced by this receiver can be found in metadata.yaml

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(ctx context.Context, config *Config, logger *zap.Logger) (client, error)

NewClient creates a new client to connect and query mongo for the mongodbreceiver

func NewFactory

func NewFactory() receiver.Factory

NewFactory creates a factory for mongodb receiver.

Types

type Config

type Config struct {
	scraperhelper.ScraperControllerSettings `mapstructure:",squash"`
	configtls.TLSClientSetting              `mapstructure:"tls,omitempty"`
	// Metrics defines which metrics to enable for the scraper
	Metrics    metadata.MetricsSettings `mapstructure:"metrics"`
	Hosts      []confignet.NetAddr      `mapstructure:"hosts"`
	Username   string                   `mapstructure:"username"`
	Password   string                   `mapstructure:"password"`
	ReplicaSet string                   `mapstructure:"replica_set,omitempty"`
	Timeout    time.Duration            `mapstructure:"timeout"`
}

func (*Config) ClientOptions

func (c *Config) ClientOptions() *options.ClientOptions

func (*Config) Validate

func (c *Config) Validate() error

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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