mongodbatlasreceiver

package module
v0.99.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 37 Imported by: 8

README

MongoDB Atlas Receiver

Status
Stability beta: metrics, logs
Distributions contrib
Issues Open issues Closed issues
Code Owners @djaglowski, @schmikei | Seeking more code owners!

Receives metrics from MongoDB Atlas via their monitoring APIs, as well as alerts via a configured webhook and events from events APIs.

Getting Started

The MongoDB Atlas receiver takes the following parameters. public_key and private_key are the only two required values to receive metrics and logs and are obtained via the "API Keys" tab of the MongoDB Atlas Project Access Manager. In the example below both values are being pulled from the environment.

In order to collect logs, at least one project must be specified. By default, logs for all clusters within a project will be collected. Clusters can be limited using either the include_clusters or exclude_clusters setting.

In order to collect project events, the requesting API key needs the appropriate permission which at minimum is the Project Read Only role. Project events are specific to a single project.

In order to collect organization events, the requesting API key needs the appropriate permission which at minimum is the Organization Member role. Organization events are collected across all the projects hosted on Atlas within the organization. These events are not associated with a project.

In order to collect access logs, the requesting API key needs the appropriate permission which requires either the Project Owner or Organization Owner role. Access logs are specific to each cluster.

MongoDB Atlas Documentation recommends a polling interval of 5 minutes.

  • public_key (required for metrics, logs, or alerts in poll mode)
  • private_key (required for metrics, logs, or alerts in poll mode)
  • granularity (default PT1M - See MongoDB Atlas Documentation)
  • collection_interval (default 3m) This receiver collects metrics on an interval. Valid time units are ns, us (or µs), ms, s, m, h.
  • storage (optional) The component ID of a storage extension which can be used when polling for alerts or events . The storage extension prevents duplication of data after a collector restart by remembering which data were previously collected.
  • projects (optional for metrics) a slice of projects this receiver collects metrics from instead of all projects in an organization
    • name Name of the project to discover metrics from
    • include_clusters (default empty, exclusive with exclude_clusters)
    • exclude_clusters (default empty, exclusive with include_clusters)
      • If both include_clusters and exclude_clusters are empty, then all clusters in the project will be included
  • retry_on_failure
    • enabled (default true)
    • initial_interval (default 5s)
    • max_interval (default 30s)
    • max_elapsed_time (default 5m)
  • alerts
    • enabled (default false)
    • mode (default listen. Options are poll or listen)
    • secret (required if using listen mode)
    • endpoint (required if using listen mode)
    • poll_interval (default 5m, only relevant using poll mode)
    • page_size (default 100)
      • When in poll mode, this is the number of alerts that will be processed per request to the MongoDB Atlas API.
    • max_pages (default 10)
      • When in poll mode, this will limit how many pages of alerts the receiver will request for each project.
    • projects (required if using poll mode)
      • name (required if using poll mode)
      • include_clusters (default empty, exclusive with exclude_clusters)
      • exclude_clusters (default empty, exclusive with include_clusters)
        • If both include_clusters and exclude_clusters are empty, then all clusters in the project will be included
    • tls (relevant only for listen mode)
      • key_file
      • cert_file
  • logs
    • enabled (default false)
    • projects (required if enabled)
      • name (required if enabled)
      • collect_host_logs (default true)
      • collect_audit_logs (default false)
      • access_logs
        • enabled (default true, if the access_logs parameter is defined)
        • auth_result
          • If specified, will limit the access logs queried to successful accesses (true) or failed accesses (false). If not specified, all will be collected
        • page_size (default 20000)
          • This is the number of access logs that will be processed per request to the MongoDB Atlas API. The maximum value is 20000.
        • max_pages (default 10)
          • This will limit how many pages of access logs the receiver will request from the MongoDB Atlas API for a project.
        • poll_interval (default 5m)
          • This will define how frequently the MongoDB Atlas API is queried for Access Logs for the given project.
      • include_clusters (default empty)
      • exclude_clusters (default empty)
  • events
    • projects
      • name Name of the Project to discover events from.
    • organizations
      • id ID of the Organization to discover events from.
    • poll_interval (default 1m)
      • How often the receiver will poll the Events API for new events.
    • page_size (default 100)
      • This is the number of events that will be processed per request to the MongoDB Atlas API.
    • max_pages (default 25)
      • This will limit how many pages of events the receiver will request from the MongoDB Atlas API for each project.
    • types (defaults to all types of events)
      • This is a list of event types that the receiver will request from the API. If specified, the receiver will collect only the indicated types of events.

Examples:

Receive metrics:

receivers:
  mongodbatlas:
    public_key: ${env:MONGODB_ATLAS_PUBLIC_KEY}
    private_key: ${env:MONGODB_ATLAS_PRIVATE_KEY}

Listen for alerts (default mode):

receivers:
  mongodbatlas:
    alerts:
      enabled: true
      secret: "some_secret"
      endpoint: "0.0.0.0:7706"

Poll alerts from API:

receivers:
  mongodbatlas:
    public_key: <redacted>
    private_key: <redacted>
    alerts:
      enabled: true
      mode: poll
      projects:
      - name: Project 0
        include_clusters: [Cluster0]
      poll_interval: 1m
    # use of a storage extension is recommended to reduce chance of duplicated alerts
    storage: file_storage

Receive logs:

receivers:
  mongodbatlas:
    logs:
      enabled: true
      projects: 
        - name: "project 1"
          collect_audit_logs: true
          collect_host_logs: true

Receive events:

receivers:
  mongodbatlas:
    events:
      projects:
        - name: "project 1"
      organizations:
        - id: "5b478b3afc4625789ce616a3"
      poll_interval: 1m
      page_size: 100
      max_pages: 25
    # use of a storage extension is recommended to reduce chance of duplicated events
    storage: file_storage

Poll Access Logs from API:

receivers:
  mongodbatlas:
    public_key: <redacted>
    private_key: <redacted>
    logs:
      enabled: true
      projects:
      - name: Project 0
        include_clusters: [Cluster0]
        access_logs:
          page_size: 20000
          max_pages: 10
          poll_interval: 5m
    # use of a storage extension is recommended to reduce chance of duplicated access logs
    storage: file_storage

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() receiver.Factory

NewFactory creates a factory for MongoDB Atlas receiver

Types

type AccessLogsConfig added in v0.78.0

type AccessLogsConfig struct {
	Enabled      *bool         `mapstructure:"enabled"`
	PollInterval time.Duration `mapstructure:"poll_interval"`
	PageSize     int64         `mapstructure:"page_size"`
	MaxPages     int64         `mapstructure:"max_pages"`
	AuthResult   *bool         `mapstructure:"auth_result"`
}

func (*AccessLogsConfig) IsEnabled added in v0.78.0

func (alc *AccessLogsConfig) IsEnabled() bool

type AlertConfig added in v0.54.0

type AlertConfig struct {
	Enabled  bool                    `mapstructure:"enabled"`
	Endpoint string                  `mapstructure:"endpoint"`
	Secret   configopaque.String     `mapstructure:"secret"`
	TLS      *configtls.ServerConfig `mapstructure:"tls"`
	Mode     string                  `mapstructure:"mode"`

	// these parameters are only relevant in retrieval mode
	Projects     []*ProjectConfig `mapstructure:"projects"`
	PollInterval time.Duration    `mapstructure:"poll_interval"`
	PageSize     int64            `mapstructure:"page_size"`
	MaxPages     int64            `mapstructure:"max_pages"`
}

type ClusterInfo added in v0.89.0

type ClusterInfo struct {
	ClusterName         string
	RegionName          string
	ProviderName        string
	MongoDBMajorVersion string
}

type Config

type Config struct {
	scraperhelper.ControllerConfig `mapstructure:",squash"`
	PublicKey                      string                        `mapstructure:"public_key"`
	PrivateKey                     configopaque.String           `mapstructure:"private_key"`
	Granularity                    string                        `mapstructure:"granularity"`
	MetricsBuilderConfig           metadata.MetricsBuilderConfig `mapstructure:",squash"`
	Projects                       []*ProjectConfig              `mapstructure:"projects"`
	Alerts                         AlertConfig                   `mapstructure:"alerts"`
	Events                         *EventsConfig                 `mapstructure:"events"`
	Logs                           LogConfig                     `mapstructure:"logs"`
	BackOffConfig                  configretry.BackOffConfig     `mapstructure:"retry_on_failure"`
	StorageID                      *component.ID                 `mapstructure:"storage"`
}

func (*Config) Validate added in v0.54.0

func (c *Config) Validate() error

type EventsConfig added in v0.71.0

type EventsConfig struct {
	Projects      []*ProjectConfig `mapstructure:"projects"`
	Organizations []*OrgConfig     `mapstructure:"organizations"`
	PollInterval  time.Duration    `mapstructure:"poll_interval"`
	Types         []string         `mapstructure:"types"`
	PageSize      int64            `mapstructure:"page_size"`
	MaxPages      int64            `mapstructure:"max_pages"`
}

EventsConfig is the configuration options for events collection

type LogConfig added in v0.59.0

type LogConfig struct {
	Enabled  bool                 `mapstructure:"enabled"`
	Projects []*LogsProjectConfig `mapstructure:"projects"`
}

type LogsProjectConfig added in v0.78.0

type LogsProjectConfig struct {
	ProjectConfig `mapstructure:",squash"`

	EnableAuditLogs bool              `mapstructure:"collect_audit_logs"`
	EnableHostLogs  *bool             `mapstructure:"collect_host_logs"`
	AccessLogs      *AccessLogsConfig `mapstructure:"access_logs"`
}

type OrgConfig added in v0.75.0

type OrgConfig struct {
	ID string `mapstructure:"id"`
}

type ProjectConfig added in v0.59.0

type ProjectConfig struct {
	Name            string   `mapstructure:"name"`
	ExcludeClusters []string `mapstructure:"exclude_clusters"`
	IncludeClusters []string `mapstructure:"include_clusters"`
	// contains filtered or unexported fields
}

type ProjectContext added in v0.59.0

type ProjectContext struct {
	Project mongodbatlas.Project
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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