mongodb

package
v0.0.0-...-5655933 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 19 Imported by: 0

README

mongodb

mongodb 监控采集插件,v0.3.30开始从telegraf/mongodb fork而来,支持mongodb 3.6+版本。

Configuration

  • 配置文件,参考示例
  • 配置权限,至少授予以下权限给配置文件中用于连接 MongoDB 的 user 才能收集指标:
    {
         "role":"clusterMonitor",
         "db":"admin"
      },
      {
         "role":"read",
         "db":"local"
      }
    
    
    一个简单配置
    mongo -h xxx -u xxx -p xxx --authenticationDatabase admin
    > use admin
    > db.createUser({user:"categraf",pwd:"categraf",roles: [{role:"read",db:"local"},{"role":"clusterMonitor","db":"admin"}]})
    
    更详细的权限配置请参考官方文档

监控大盘和告警规则

同级目录下的 dashboard.json、alerts.json 是大盘和告警规则, dashboard2.json 是v0.3.30版本以后的大盘。

Documentation

Index

Constants

View Source
const (
	Always   = 1 << iota // always activate the column
	Discover             // only active when mongostat is in discover mode
	Repl                 // only active if one of the nodes being monitored is in a replset
	Locks                // only active if node is capable of calculating lock info
	AllOnly              // only active if mongostat was run with --all option
	MMAPOnly             // only active if node has mmap-specific fields
	WTOnly               // only active if node has wiredtiger-specific fields
)

Flags to determine cases when to activate/deactivate columns for output.

View Source
const (
	MongosProcess = "mongos"
)

Variables

View Source
var StatHeaders = []StatHeader{
	{"", Always},
	{"insert", Always},
	{"query", Always},
	{"update", Always},
	{"delete", Always},
	{"getmore", Always},
	{"command", Always},
	{"% dirty", WTOnly},
	{"% used", WTOnly},
	{"flushes", Always},
	{"mapped", MMAPOnly},
	{"vsize", Always},
	{"res", Always},
	{"non-mapped", MMAPOnly | AllOnly},
	{"faults", MMAPOnly},
	{"lr|lw %", MMAPOnly | AllOnly},
	{"lrt|lwt", MMAPOnly | AllOnly},
	{"    locked db", Locks},
	{"qr|qw", Always},
	{"ar|aw", Always},
	{"netIn", Always},
	{"netOut", Always},
	{"conn", Always},
	{"set", Repl},
	{"repl", Repl},
	{"time", Always},
}

StatHeaders are the complete set of data metrics supported by mongostat.

Functions

func IsAuthorization

func IsAuthorization(err error) bool

Types

type AssertsStats

type AssertsStats struct {
	Regular   int64 `bson:"regular"`
	Warning   int64 `bson:"warning"`
	Msg       int64 `bson:"msg"`
	User      int64 `bson:"user"`
	Rollovers int64 `bson:"rollovers"`
}

AssertsStats stores information related to assertions raised since the MongoDB process started

type BasicStats

type BasicStats struct {
	Num         int64 `bson:"num"`
	TotalMillis int64 `bson:"totalMillis"`
}

BasicStats stores information about an operation

type CacheStats

type CacheStats struct {
	TrackedDirtyBytes         int64 `bson:"tracked dirty bytes in the cache"`
	CurrentCachedBytes        int64 `bson:"bytes currently in the cache"`
	MaxBytesConfigured        int64 `bson:"maximum bytes configured"`
	AppThreadsPageReadCount   int64 `bson:"application threads page read from disk to cache count"`
	AppThreadsPageReadTime    int64 `bson:"application threads page read from disk to cache time (usecs)"`
	AppThreadsPageWriteCount  int64 `bson:"application threads page write from cache to disk count"`
	AppThreadsPageWriteTime   int64 `bson:"application threads page write from cache to disk time (usecs)"`
	BytesWrittenFrom          int64 `bson:"bytes written from cache"`
	BytesReadInto             int64 `bson:"bytes read into cache"`
	PagesEvictedByAppThread   int64 `bson:"pages evicted by application threads"`
	PagesQueuedForEviction    int64 `bson:"pages queued for eviction"`
	PagesReadIntoCache        int64 `bson:"pages read into cache"`
	PagesWrittenFromCache     int64 `bson:"pages written from cache"`
	PagesRequestedFromCache   int64 `bson:"pages requested from the cache"`
	ServerEvictingPages       int64 `bson:"eviction server evicting pages"`
	WorkerThreadEvictingPages int64 `bson:"eviction worker thread evicting pages"`
	InternalPagesEvicted      int64 `bson:"internal pages evicted"`
	ModifiedPagesEvicted      int64 `bson:"modified pages evicted"`
	UnmodifiedPagesEvicted    int64 `bson:"unmodified pages evicted"`
}

CacheStats stores cache statistics for WiredTiger.

type ClientStats

type ClientStats struct {
	Total   int64 `bson:"total"`
	Readers int64 `bson:"readers"`
	Writers int64 `bson:"writers"`
}

ClientStats stores the number of active read/write operations.

type ClusterStatus

type ClusterStatus struct {
	JumboChunksCount int64
}

ClusterStatus stores information related to the whole cluster

type ColData

type ColData struct {
	Name   string
	DbName string
	Fields map[string]interface{}
}

type ColStatLine

type ColStatLine struct {
	Name           string
	DbName         string
	Count          int64
	Size           int64
	AvgObjSize     float64
	StorageSize    int64
	TotalIndexSize int64
	Ok             int64
}

type ColStats

type ColStats struct {
	Collections []Collection
}

type ColStatsData

type ColStatsData struct {
	Collection     string  `bson:"ns"`
	Count          int64   `bson:"count"`
	Size           int64   `bson:"size"`
	AvgObjSize     float64 `bson:"avgObjSize"`
	StorageSize    int64   `bson:"storageSize"`
	TotalIndexSize int64   `bson:"totalIndexSize"`
	Ok             int64   `bson:"ok"`
}

type Collection

type Collection struct {
	Name         string
	DbName       string
	ColStatsData *ColStatsData
}

type CollectionLockStatus

type CollectionLockStatus struct {
	ReadAcquireWaitsPercentage  float64
	WriteAcquireWaitsPercentage float64
	ReadAcquireTimeMicros       int64
	WriteAcquireTimeMicros      int64
}

CollectionLockStatus stores a collection's lock statistics.

type CommandsStats

type CommandsStats struct {
	Aggregate     *CommandsStatsValue `bson:"aggregate"`
	Count         *CommandsStatsValue `bson:"count"`
	Delete        *CommandsStatsValue `bson:"delete"`
	Distinct      *CommandsStatsValue `bson:"distinct"`
	Find          *CommandsStatsValue `bson:"find"`
	FindAndModify *CommandsStatsValue `bson:"findAndModify"`
	GetMore       *CommandsStatsValue `bson:"getMore"`
	Insert        *CommandsStatsValue `bson:"insert"`
	Update        *CommandsStatsValue `bson:"update"`
}

CommandsStats stores information related to document metrics.

type CommandsStatsValue

type CommandsStatsValue struct {
	Failed int64 `bson:"failed"`
	Total  int64 `bson:"total"`
}

type ConcurrentTransStats

type ConcurrentTransStats struct {
	Out          int64 `bson:"out"`
	Available    int64 `bson:"available"`
	TotalTickets int64 `bson:"totalTickets"`
}

type ConcurrentTransactions

type ConcurrentTransactions struct {
	Write ConcurrentTransStats `bson:"write"`
	Read  ConcurrentTransStats `bson:"read"`
}

type ConnectionStats

type ConnectionStats struct {
	Current      int64 `bson:"current"`
	Available    int64 `bson:"available"`
	TotalCreated int64 `bson:"totalCreated"`
}

ConnectionStats stores information related to incoming database connections.

type CursorStats

type CursorStats struct {
	TimedOut int64            `bson:"timedOut"`
	Open     *OpenCursorStats `bson:"open"`
}

CursorStats stores information related to cursor metrics.

type DBRecordStats

type DBRecordStats struct {
	AccessesNotInMemory       int64                     `bson:"accessesNotInMemory"`
	PageFaultExceptionsThrown int64                     `bson:"pageFaultExceptionsThrown"`
	DBRecordAccesses          map[string]RecordAccesses `bson:",inline"`
}

DBRecordStats stores data related to memory operations across databases.

type DataHandleStats

type DataHandleStats struct {
	DataHandlesCurrentlyActive int64 `bson:"connection data handles currently active"`
}

DataHandleStats stores statistics for wiredTiger data-handles

type Db

type Db struct {
	Name        string
	DbStatsData *DbStatsData
}

Db represent a single DB

type DbData

type DbData struct {
	Name   string
	Fields map[string]interface{}
}

type DbStatLine

type DbStatLine struct {
	Name        string
	Collections int64
	Objects     int64
	AvgObjSize  float64
	DataSize    int64
	StorageSize int64
	NumExtents  int64
	Indexes     int64
	IndexSize   int64
	Ok          int64
	FsUsedSize  int64
	FsTotalSize int64
}

type DbStats

type DbStats struct {
	Dbs []Db
}

DbStats stores stats from all dbs

type DbStatsData

type DbStatsData struct {
	Db          string      `bson:"db"`
	Collections int64       `bson:"collections"`
	Objects     int64       `bson:"objects"`
	AvgObjSize  float64     `bson:"avgObjSize"`
	DataSize    int64       `bson:"dataSize"`
	StorageSize int64       `bson:"storageSize"`
	NumExtents  int64       `bson:"numExtents"`
	Indexes     int64       `bson:"indexes"`
	IndexSize   int64       `bson:"indexSize"`
	Ok          int64       `bson:"ok"`
	GleStats    interface{} `bson:"gleStats"`
	FsUsedSize  int64       `bson:"fsUsedSize"`
	FsTotalSize int64       `bson:"fsTotalSize"`
}

DbStatsData stores stats from a db

type DetailedTCMallocStats

type DetailedTCMallocStats struct {
	PageheapFreeBytes            int64 `bson:"pageheap_free_bytes"`
	PageheapUnmappedBytes        int64 `bson:"pageheap_unmapped_bytes"`
	MaxTotalThreadCacheBytes     int64 `bson:"max_total_thread_cache_bytes"`
	CurrentTotalThreadCacheBytes int64 `bson:"current_total_thread_cache_bytes"`
	TotalFreeBytes               int64 `bson:"total_free_bytes"`
	CentralCacheFreeBytes        int64 `bson:"central_cache_free_bytes"`
	TransferCacheFreeBytes       int64 `bson:"transfer_cache_free_bytes"`
	ThreadCacheFreeBytes         int64 `bson:"thread_cache_free_bytes"`
	PageheapComittedBytes        int64 `bson:"pageheap_committed_bytes"`
	PageheapScavengeCount        int64 `bson:"pageheap_scavenge_count"`
	PageheapCommitCount          int64 `bson:"pageheap_commit_count"`
	PageheapTotalCommitBytes     int64 `bson:"pageheap_total_commit_bytes"`
	PageheapDecommitCount        int64 `bson:"pageheap_decommit_count"`
	PageheapTotalDecommitBytes   int64 `bson:"pageheap_total_decommit_bytes"`
	PageheapReserveCount         int64 `bson:"pageheap_reserve_count"`
	PageheapTotalReserveBytes    int64 `bson:"pageheap_total_reserve_bytes"`
	SpinLockTotalDelayNanos      int64 `bson:"spinlock_total_delay_ns"`
}

DetailedTCMallocStats stores detailed TCMalloc memory allocator metrics

type DocumentStats

type DocumentStats struct {
	Deleted  int64 `bson:"deleted"`
	Inserted int64 `bson:"inserted"`
	Returned int64 `bson:"returned"`
	Updated  int64 `bson:"updated"`
}

DocumentStats stores information related to document metrics.

type DurStats

type DurStats struct {
	Commits            float64 `bson:"commits"`
	JournaledMB        float64 `bson:"journaledMB"`
	WriteToDataFilesMB float64 `bson:"writeToDataFilesMB"`
	Compression        float64 `bson:"compression"`
	CommitsInWriteLock float64 `bson:"commitsInWriteLock"`
	EarlyCommits       float64 `bson:"earlyCommits"`
	TimeMs             DurTiming
}

DurStats stores information related to journaling statistics.

type DurTiming

type DurTiming struct {
	Dt               int64 `bson:"dt"`
	PrepLogBuffer    int64 `bson:"prepLogBuffer"`
	WriteToJournal   int64 `bson:"writeToJournal"`
	WriteToDataFiles int64 `bson:"writeToDataFiles"`
	RemapPrivateView int64 `bson:"remapPrivateView"`
}

DurTiming stores information related to journaling.

type ExtraInfo

type ExtraInfo struct {
	PageFaults *int64 `bson:"page_faults"`
}

ExtraInfo stores additional platform specific information.

type FlushStats

type FlushStats struct {
	Flushes      int64     `bson:"flushes"`
	TotalMs      int64     `bson:"total_ms"`
	AverageMs    float64   `bson:"average_ms"`
	LastMs       int64     `bson:"last_ms"`
	LastFinished time.Time `bson:"last_finished"`
}

FlushStats stores information about memory flushes.

type GenericTCMAllocStats

type GenericTCMAllocStats struct {
	CurrentAllocatedBytes int64 `bson:"current_allocated_bytes"`
	HeapSize              int64 `bson:"heap_size"`
}

GenericTCMAllocStats stores generic TCMalloc memory allocator metrics

type GlobalLockStats

type GlobalLockStats struct {
	TotalTime     int64        `bson:"totalTime"`
	LockTime      int64        `bson:"lockTime"`
	CurrentQueue  *QueueStats  `bson:"currentQueue"`
	ActiveClients *ClientStats `bson:"activeClients"`
}

GlobalLockStats stores information related locks in the MMAP storage engine.

type Instance

type Instance struct {
	config.InstanceConfig

	// telegraf
	Servers                     []string
	Ssl                         Ssl
	GatherClusterStatus         bool `toml:"enable_cluster_status,omitempty"`
	EnableReplicasetStatus      bool `toml:"enable_replicaset_status,omitempty"`
	EnableDBStats               bool `toml:"enable_db_stats,omitempty"`
	EnableCollStats             bool `toml:"enable_coll_stats,omitempty"`
	EnableTopMetrics            bool `toml:"enable_top_metrics,omitempty"`
	DisconnectedServersBehavior string
	ColStatsDbs                 []string `toml:"coll_stats_namespaces,omitempty"`
	CollectAll                  bool     `toml:"collect_all,omitempty"`

	//
	tls.ClientConfig

	// Address (host:port) of MongoDB server.
	MongodbURI                    string   `toml:"mongodb_uri,omitempty"` // deprecated
	Username                      string   `toml:"username,omitempty"`
	Password                      string   `toml:"password,omitempty"`
	IndexStatsCollections         []string `toml:"index_stats_collections,omitempty"` // 保留 ,就加过滤逻辑
	CollStatsLimit                int      `toml:"coll_stats_limit,omitempty"`
	CompatibleMode                bool     `toml:"compatible_mode,omitempty"`
	DirectConnect                 bool     `toml:"direct_connect,omitempty"`
	DiscoveringMode               bool     `toml:"discovering_mode,omitempty"`
	EnableDiagnosticData          bool     `toml:"enable_diagnostic_data,omitempty"`
	EnableIndexStats              bool     `toml:"enable_index_stats,omitempty"`
	EnableOverrideDescendingIndex bool     `toml:"enable_override_descending_index,omitempty"`

	Queries []QueryConfig
	// contains filtered or unexported fields
}

func (*Instance) Gather

func (ins *Instance) Gather(slist *types.SampleList)

func (*Instance) Init

func (ins *Instance) Init() error

type LatencyStats

type LatencyStats struct {
	Latency int64 `bson:"latency"`
	Ops     int64 `bson:"ops"`
}

LatencyStats lists total latency in microseconds and count of operations, enabling you to obtain an average

type LockStats

type LockStats struct {
	TimeLockedMicros    ReadWriteLockTimes `bson:"timeLockedMicros"`
	TimeAcquiringMicros ReadWriteLockTimes `bson:"timeAcquiringMicros"`

	// AcquireCount and AcquireWaitCount are new fields of the lock stats only populated on 3.0 or newer.
	// Typed as a pointer so that if it is nil, mongostat can assume the field is not populated
	// with real namespace data.
	AcquireCount     *ReadWriteLockTimes `bson:"acquireCount,omitempty"`
	AcquireWaitCount *ReadWriteLockTimes `bson:"acquireWaitCount,omitempty"`
}

LockStats stores information related to time spent acquiring/holding locks for a given database.

type LockStatus

type LockStatus struct {
	DBName     string
	Percentage float64
	Global     bool
}

LockStatus stores a database's lock statistics.

type LockUsage

type LockUsage struct {
	Namespace string
	Reads     int64
	Writes    int64
}

LockUsage stores information related to a namespace's lock usage.

type MemStats

type MemStats struct {
	Bits              int64       `bson:"bits"`
	Resident          int64       `bson:"resident"`
	Virtual           int64       `bson:"virtual"`
	Supported         interface{} `bson:"supported"`
	Mapped            int64       `bson:"mapped"`
	MappedWithJournal int64       `bson:"mappedWithJournal"`
}

MemStats stores data related to memory statistics.

type MetricsStats

type MetricsStats struct {
	TTL           *TTLStats           `bson:"ttl"`
	Cursor        *CursorStats        `bson:"cursor"`
	Document      *DocumentStats      `bson:"document"`
	Commands      *CommandsStats      `bson:"commands"`
	Operation     *OperationStats     `bson:"operation"`
	QueryExecutor *QueryExecutorStats `bson:"queryExecutor"`
	Repl          *ReplStats          `bson:"repl"`
	Storage       *StorageStats       `bson:"storage"`
}

MetricsStats stores information related to metrics

type MongoDB

type MongoDB struct {
	config.PluginConfig
	Instances []*Instance `toml:"instances"`
}

func (*MongoDB) Clone

func (r *MongoDB) Clone() inputs.Input

func (*MongoDB) Drop

func (r *MongoDB) Drop()

func (*MongoDB) GetInstances

func (r *MongoDB) GetInstances() []inputs.Instance

func (*MongoDB) Name

func (r *MongoDB) Name() string

type MongoStatus

type MongoStatus struct {
	SampleTime    time.Time
	ServerStatus  *ServerStatus
	ReplSetStatus *ReplSetStatus
	ClusterStatus *ClusterStatus
	DbStats       *DbStats
	ColStats      *ColStats
	ShardStats    *ShardStats
	OplogStats    *OplogStats
	TopStats      *TopStats
}

type MongodbData

type MongodbData struct {
	StatLine      *StatLine
	Fields        map[string]interface{}
	Tags          map[string]string
	DbData        []DbData
	ColData       []ColData
	ShardHostData []DbData
	TopStatsData  []DbData
}

func NewMongodbData

func NewMongodbData(statLine *StatLine, tags map[string]string) *MongodbData

func (*MongodbData) AddColStats

func (d *MongodbData) AddColStats()

func (*MongodbData) AddDbStats

func (d *MongodbData) AddDbStats()

func (*MongodbData) AddDefaultStats

func (d *MongodbData) AddDefaultStats()

func (*MongodbData) AddShardHostStats

func (d *MongodbData) AddShardHostStats()

func (*MongodbData) AddTopStats

func (d *MongodbData) AddTopStats()

type NamespacedLocks

type NamespacedLocks map[string]LockStatus

NamespacedLocks stores information on the LockStatus of namespaces.

type NetworkStats

type NetworkStats struct {
	BytesIn     int64 `bson:"bytesIn"`
	BytesOut    int64 `bson:"bytesOut"`
	NumRequests int64 `bson:"numRequests"`
}

NetworkStats stores information related to network traffic.

type OpLatenciesStats

type OpLatenciesStats struct {
	Reads    *LatencyStats `bson:"reads"`
	Writes   *LatencyStats `bson:"writes"`
	Commands *LatencyStats `bson:"commands"`
}

OpLatenciesStats stores information related to operation latencies for the database as a whole

type OpcountStats

type OpcountStats struct {
	Insert  int64 `bson:"insert"`
	Query   int64 `bson:"query"`
	Update  int64 `bson:"update"`
	Delete  int64 `bson:"delete"`
	GetMore int64 `bson:"getmore"`
	Command int64 `bson:"command"`
}

OpcountStats stores information related to commands and basic CRUD operations.

type OpenCursorStats

type OpenCursorStats struct {
	NoTimeout int64 `bson:"noTimeout"`
	Pinned    int64 `bson:"pinned"`
	Total     int64 `bson:"total"`
}

OpenCursorStats stores information related to open cursor metrics

type OperationStats

type OperationStats struct {
	ScanAndOrder   int64 `bson:"scanAndOrder"`
	WriteConflicts int64 `bson:"writeConflicts"`
}

OperationStats stores information related to query operations using special operation types

type OplogStats

type OplogStats struct {
	TimeDiff int64
}

OplogStatus stores information from getReplicationInfo

type QueryConfig

type QueryConfig struct {
	Mesurement    string          `toml:"mesurement"`
	LabelFields   []string        `toml:"label_fields"`
	MetricFields  []string        `toml:"metric_fields"`
	FieldToAppend string          `toml:"field_to_append"`
	Timeout       config.Duration `toml:"timeout"`
	Request       string          `toml:"request"`
}

type QueryExecutorStats

type QueryExecutorStats struct {
	Scanned        int64 `bson:"scanned"`
	ScannedObjects int64 `bson:"scannedObjects"`
}

QueryExecutorStats stores information related to query execution

type QueueStats

type QueueStats struct {
	Total   int64 `bson:"total"`
	Readers int64 `bson:"readers"`
	Writers int64 `bson:"writers"`
}

QueueStats stores the number of queued read/write operations.

type ReadWriteLockTimes

type ReadWriteLockTimes struct {
	Read       int64 `bson:"R"`
	Write      int64 `bson:"W"`
	ReadLower  int64 `bson:"r"`
	WriteLower int64 `bson:"w"`
}

ReadWriteLockTimes stores time spent holding read/write locks.

type RecordAccesses

type RecordAccesses struct {
	AccessesNotInMemory       int64 `bson:"accessesNotInMemory"`
	PageFaultExceptionsThrown int64 `bson:"pageFaultExceptionsThrown"`
}

RecordAccesses stores data related to memory operations scoped to a database.

type ReplApplyStats

type ReplApplyStats struct {
	Batches *BasicStats `bson:"batches"`
	Ops     int64       `bson:"ops"`
}

ReplApplyStats stores information related to oplog application process

type ReplBufferStats

type ReplBufferStats struct {
	Count     int64 `bson:"count"`
	SizeBytes int64 `bson:"sizeBytes"`
}

ReplBufferStats stores information related to oplog buffer

type ReplExecutorStats

type ReplExecutorStats struct {
	Pool             map[string]int64 `bson:"pool"`
	Queues           map[string]int64 `bson:"queues"`
	UnsignaledEvents int64            `bson:"unsignaledEvents"`
}

ReplExecutorStats stores information related to replication executor

type ReplNetworkStats

type ReplNetworkStats struct {
	Bytes    int64       `bson:"bytes"`
	GetMores *BasicStats `bson:"getmores"`
	Ops      int64       `bson:"ops"`
}

ReplNetworkStats stores information related to network usage by replication process

type ReplSetMember

type ReplSetMember struct {
	Name       string    `bson:"name"`
	Health     int64     `bson:"health"`
	State      int64     `bson:"state"`
	StateStr   string    `bson:"stateStr"`
	OptimeDate time.Time `bson:"optimeDate"`
}

ReplSetMember stores information related to a replica set member

type ReplSetStatus

type ReplSetStatus struct {
	Members []ReplSetMember `bson:"members"`
	MyState int64           `bson:"myState"`
}

ReplSetStatus stores information from replSetGetStatus

type ReplStats

type ReplStats struct {
	Apply    *ReplApplyStats    `bson:"apply"`
	Buffer   *ReplBufferStats   `bson:"buffer"`
	Executor *ReplExecutorStats `bson:"executor,omitempty"`
	Network  *ReplNetworkStats  `bson:"network"`
}

ReplStats stores information related to replication process

type ReplStatus

type ReplStatus struct {
	SetName           string      `bson:"setName"`
	IsWritablePrimary interface{} `bson:"isWritablePrimary"` // mongodb 5.x
	IsMaster          interface{} `bson:"ismaster"`
	Secondary         interface{} `bson:"secondary"`
	IsReplicaSet      interface{} `bson:"isreplicaset"`
	ArbiterOnly       interface{} `bson:"arbiterOnly"`
	Hosts             []string    `bson:"hosts"`
	Passives          []string    `bson:"passives"`
	Me                string      `bson:"me"`
}

ReplStatus stores data related to replica sets.

type Server

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

type ServerStatus

type ServerStatus struct {
	SampleTime         time.Time              `bson:""`
	Flattened          map[string]interface{} `bson:""`
	Host               string                 `bson:"host"`
	Version            string                 `bson:"version"`
	Process            string                 `bson:"process"`
	Pid                int64                  `bson:"pid"`
	Uptime             int64                  `bson:"uptime"`
	UptimeMillis       int64                  `bson:"uptimeMillis"`
	UptimeEstimate     int64                  `bson:"uptimeEstimate"`
	LocalTime          time.Time              `bson:"localTime"`
	Asserts            *AssertsStats          `bson:"asserts"`
	BackgroundFlushing *FlushStats            `bson:"backgroundFlushing"`
	ExtraInfo          *ExtraInfo             `bson:"extra_info"`
	Connections        *ConnectionStats       `bson:"connections"`
	Dur                *DurStats              `bson:"dur"`
	GlobalLock         *GlobalLockStats       `bson:"globalLock"`
	Locks              map[string]LockStats   `bson:"locks,omitempty"`
	Network            *NetworkStats          `bson:"network"`
	Opcounters         *OpcountStats          `bson:"opcounters"`
	OpcountersRepl     *OpcountStats          `bson:"opcountersRepl"`
	OpLatencies        *OpLatenciesStats      `bson:"opLatencies"`
	RecordStats        *DBRecordStats         `bson:"recordStats"`
	Mem                *MemStats              `bson:"mem"`
	Repl               *ReplStatus            `bson:"repl"`
	ShardCursorType    map[string]interface{} `bson:"shardCursorType"`
	StorageEngine      *StorageEngine         `bson:"storageEngine"`
	WiredTiger         *WiredTiger            `bson:"wiredTiger"`
	Metrics            *MetricsStats          `bson:"metrics"`
	TCMallocStats      *TCMallocStats         `bson:"tcmalloc"`
}

type ShardHostStatLine

type ShardHostStatLine struct {
	InUse      int64
	Available  int64
	Created    int64
	Refreshing int64
}

type ShardHostStatsData

type ShardHostStatsData struct {
	InUse      int64 `bson:"inUse"`
	Available  int64 `bson:"available"`
	Created    int64 `bson:"created"`
	Refreshing int64 `bson:"refreshing"`
}

ShardHostStatsData is the host-specific stats from shardConnPoolStats database command.

type ShardStats

type ShardStats struct {
	ShardStatsData `bson:",inline"`
	Hosts          map[string]ShardHostStatsData `bson:"hosts"`
}

ShardStats stores information from shardConnPoolStats.

type ShardStatsData

type ShardStatsData struct {
	TotalInUse      int64 `bson:"totalInUse"`
	TotalAvailable  int64 `bson:"totalAvailable"`
	TotalCreated    int64 `bson:"totalCreated"`
	TotalRefreshing int64 `bson:"totalRefreshing"`
}

ShardStatsData is the total Shard Stats from shardConnPoolStats database command.

type Ssl

type Ssl struct {
	Enabled bool     `toml:"ssl_enabled" deprecated:"1.3.0;use 'tls_*' options instead"`
	CaCerts []string `toml:"cacerts" deprecated:"1.3.0;use 'tls_ca' instead"`
}

type StatHeader

type StatHeader struct {
	// The text to appear in the column's header cell
	HeaderText string

	// Bitmask containing flags to determine if this header is active or not
	ActivateFlags int
}

StatHeader describes a single column for mongostat's terminal output, its formatting, and in which modes it should be displayed.

type StatLine

type StatLine struct {
	Key string
	// What storage engine is being used for the node with this stat line
	StorageEngine string

	Error    error
	IsMongos bool
	Host     string
	Version  string

	UptimeNanos int64
	// network
	NetworkInBytes, NetworkOutBytes int64
	// global lock
	GlobalLockTotalTime, GlobalLockLockTime int64
	GlobalLockCurrentQueue                  int64
	GlobalLockActiveClientsTotal            int64
	GlobalLockActiveClientsWriters          int64
	GlobalLockActiveClientsReaders          int64

	// The time at which this StatLine was generated.
	Time time.Time

	// The last time at which this StatLine was printed to output.
	LastPrinted time.Time

	// Opcounter fields
	Insert, InsertCnt   int64
	Query, QueryCnt     int64
	Update, UpdateCnt   int64
	Delete, DeleteCnt   int64
	GetMore, GetMoreCnt int64
	Command, CommandCnt int64

	// Asserts fields
	Regular   int64
	Warning   int64
	Msg       int64
	User      int64
	Rollovers int64

	// OpLatency fields
	WriteOpsCnt    int64
	WriteLatency   int64
	ReadOpsCnt     int64
	ReadLatency    int64
	CommandOpsCnt  int64
	CommandLatency int64

	// TTL fields
	Passes, PassesCnt                     int64
	DeletedDocuments, DeletedDocumentsCnt int64

	// Cursor fields
	TimedOutC, TimedOutCCnt   int64
	NoTimeoutC, NoTimeoutCCnt int64
	PinnedC, PinnedCCnt       int64
	TotalC, TotalCCnt         int64

	// Document fields
	DeletedD, InsertedD, ReturnedD, UpdatedD int64

	// Commands fields
	AggregateCommandTotal, AggregateCommandFailed         int64
	CountCommandTotal, CountCommandFailed                 int64
	DeleteCommandTotal, DeleteCommandFailed               int64
	DistinctCommandTotal, DistinctCommandFailed           int64
	FindCommandTotal, FindCommandFailed                   int64
	FindAndModifyCommandTotal, FindAndModifyCommandFailed int64
	GetMoreCommandTotal, GetMoreCommandFailed             int64
	InsertCommandTotal, InsertCommandFailed               int64
	UpdateCommandTotal, UpdateCommandFailed               int64

	// Operation fields
	ScanAndOrderOp, WriteConflictsOp int64

	// Query Executor fields
	TotalKeysScanned, TotalObjectsScanned int64

	// Connection fields
	CurrentC, AvailableC, TotalCreatedC int64

	// Collection locks (3.0 mmap only)
	CollectionLocks *CollectionLockStatus

	// Cache utilization (wiredtiger only)
	CacheDirtyPercent float64
	CacheUsedPercent  float64

	// Cache utilization extended (wiredtiger only)
	TrackedDirtyBytes         int64
	CurrentCachedBytes        int64
	MaxBytesConfigured        int64
	AppThreadsPageReadCount   int64
	AppThreadsPageReadTime    int64
	AppThreadsPageWriteCount  int64
	BytesWrittenFrom          int64
	BytesReadInto             int64
	PagesEvictedByAppThread   int64
	PagesQueuedForEviction    int64
	PagesReadIntoCache        int64
	PagesWrittenFromCache     int64
	PagesRequestedFromCache   int64
	ServerEvictingPages       int64
	WorkerThreadEvictingPages int64
	InternalPagesEvicted      int64
	ModifiedPagesEvicted      int64
	UnmodifiedPagesEvicted    int64

	// Connection statistics (wiredtiger only)
	FilesCurrentlyOpen int64

	// Data handles statistics (wiredtiger only)
	DataHandlesCurrentlyActive int64

	// Replicated Opcounter fields
	InsertR, InsertRCnt                      int64
	QueryR, QueryRCnt                        int64
	UpdateR, UpdateRCnt                      int64
	DeleteR, DeleteRCnt                      int64
	GetMoreR, GetMoreRCnt                    int64
	CommandR, CommandRCnt                    int64
	ReplLag                                  int64
	OplogStats                               *OplogStats
	Flushes, FlushesCnt                      int64
	FlushesTotalTime                         int64
	Mapped, Virtual, Resident, NonMapped     int64
	Faults, FaultsCnt                        int64
	HighestLocked                            *LockStatus
	QueuedReaders, QueuedWriters             int64
	ActiveReaders, ActiveWriters             int64
	AvailableReaders, AvailableWriters       int64
	TotalTicketsReaders, TotalTicketsWriters int64
	NetIn, NetInCnt                          int64
	NetOut, NetOutCnt                        int64
	NumConnections                           int64
	ReplSetName                              string
	ReplHealthAvg                            float64
	NodeType                                 string
	NodeState                                string
	NodeStateInt                             int64
	NodeHealthInt                            int64

	// Replicated Metrics fields
	ReplNetworkBytes                    int64
	ReplNetworkGetmoresNum              int64
	ReplNetworkGetmoresTotalMillis      int64
	ReplNetworkOps                      int64
	ReplBufferCount                     int64
	ReplBufferSizeBytes                 int64
	ReplApplyBatchesNum                 int64
	ReplApplyBatchesTotalMillis         int64
	ReplApplyOps                        int64
	ReplExecutorPoolInProgressCount     int64
	ReplExecutorQueuesNetworkInProgress int64
	ReplExecutorQueuesSleepers          int64
	ReplExecutorUnsignaledEvents        int64

	// Cluster fields
	JumboChunksCount int64

	// DB stats field
	DbStatsLines []DbStatLine

	// Col Stats field
	ColStatsLines []ColStatLine

	// Shard stats
	TotalInUse, TotalAvailable, TotalCreated, TotalRefreshing int64

	// Shard Hosts stats field
	ShardHostStatsLines map[string]ShardHostStatLine

	TopStatLines []TopStatLine

	// TCMalloc stats field
	TCMallocCurrentAllocatedBytes        int64
	TCMallocHeapSize                     int64
	TCMallocCentralCacheFreeBytes        int64
	TCMallocCurrentTotalThreadCacheBytes int64
	TCMallocMaxTotalThreadCacheBytes     int64
	TCMallocTotalFreeBytes               int64
	TCMallocTransferCacheFreeBytes       int64
	TCMallocThreadCacheFreeBytes         int64
	TCMallocSpinLockTotalDelayNanos      int64
	TCMallocPageheapFreeBytes            int64
	TCMallocPageheapUnmappedBytes        int64
	TCMallocPageheapComittedBytes        int64
	TCMallocPageheapScavengeCount        int64
	TCMallocPageheapCommitCount          int64
	TCMallocPageheapTotalCommitBytes     int64
	TCMallocPageheapDecommitCount        int64
	TCMallocPageheapTotalDecommitBytes   int64
	TCMallocPageheapReserveCount         int64
	TCMallocPageheapTotalReserveBytes    int64

	// Storage stats field
	StorageFreelistSearchBucketExhausted int64
	StorageFreelistSearchRequests        int64
	StorageFreelistSearchScanned         int64
}

StatLine is a wrapper for all metrics reported by mongostat for monitored hosts.

func NewStatLine

func NewStatLine(oldMongo, newMongo MongoStatus, key string, all bool, sampleSecs int64) *StatLine

NewStatLine constructs a StatLine object from two MongoStatus objects.

type StorageEngine

type StorageEngine struct {
	Name string `bson:"name"`
}

type StorageStats

type StorageStats struct {
	FreelistSearchBucketExhausted int64 `bson:"freelist.search.bucketExhausted"`
	FreelistSearchRequests        int64 `bson:"freelist.search.requests"`
	FreelistSearchScanned         int64 `bson:"freelist.search.scanned"`
}

StorageStats stores information related to record allocations

type TCMallocStats

type TCMallocStats struct {
	Generic  *GenericTCMAllocStats  `bson:"generic"`
	TCMalloc *DetailedTCMallocStats `bson:"tcmalloc"`
}

TCMallocStats stores information related to TCMalloc memory allocator metrics

type TTLStats

type TTLStats struct {
	DeletedDocuments int64 `bson:"deletedDocuments"`
	Passes           int64 `bson:"passes"`
}

TTLStats stores information related to documents with a ttl index.

type TopStatCollection

type TopStatCollection struct {
	Total     TopStatCollectionData `bson:"total"`
	ReadLock  TopStatCollectionData `bson:"readLock"`
	WriteLock TopStatCollectionData `bson:"writeLock"`
	Queries   TopStatCollectionData `bson:"queries"`
	GetMore   TopStatCollectionData `bson:"getmore"`
	Insert    TopStatCollectionData `bson:"insert"`
	Update    TopStatCollectionData `bson:"update"`
	Remove    TopStatCollectionData `bson:"remove"`
	Commands  TopStatCollectionData `bson:"commands"`
}

type TopStatCollectionData

type TopStatCollectionData struct {
	Time  int64 `bson:"time"`
	Count int64 `bson:"count"`
}

type TopStatLine

type TopStatLine struct {
	CollectionName                string
	TotalTime, TotalCount         int64
	ReadLockTime, ReadLockCount   int64
	WriteLockTime, WriteLockCount int64
	QueriesTime, QueriesCount     int64
	GetMoreTime, GetMoreCount     int64
	InsertTime, InsertCount       int64
	UpdateTime, UpdateCount       int64
	RemoveTime, RemoveCount       int64
	CommandsTime, CommandsCount   int64
}

type TopStats

type TopStats struct {
	Totals map[string]TopStatCollection `bson:"totals"`
}

type TransactionStats

type TransactionStats struct {
	TransCheckpointsTotalTimeMsecs int64 `bson:"transaction checkpoint total time (msecs)"`
	TransCheckpoints               int64 `bson:"transaction checkpoints"`
}

TransactionStats stores transaction checkpoints in WiredTiger.

type WTConnectionStats

type WTConnectionStats struct {
	FilesCurrentlyOpen int64 `bson:"files currently open"`
}

WTConnectionStats stores statistices on wiredTiger connections

type WiredTiger

type WiredTiger struct {
	Transaction TransactionStats       `bson:"transaction"`
	Concurrent  ConcurrentTransactions `bson:"concurrentTransactions"`
	Cache       CacheStats             `bson:"cache"`
	Connection  WTConnectionStats      `bson:"connection"`
	DataHandle  DataHandleStats        `bson:"data-handle"`
}

WiredTiger stores information related to the WiredTiger storage engine.

Jump to

Keyboard shortcuts

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