github.com/netdata/go.d.plugin@v0.58.1/modules/mongodb/documents.go (about) 1 // SPDX-License-Identifier: GPL-3.0-or-later 2 3 package mongo 4 5 import "time" 6 7 // https://www.mongodb.com/docs/manual/reference/command/serverStatus 8 type documentServerStatus struct { 9 Process string `bson:"process"` // mongod|mongos 10 OpCounters documentOpCounters `bson:"opcounters" stm:"operations"` 11 OpLatencies *documentOpLatencies `bson:"opLatencies" stm:"operations_latencies"` // mongod only 12 Connections documentConnections `bson:"connections" stm:"connections"` 13 Network documentNetwork `bson:"network" stm:"network"` 14 Memory documentMemory `bson:"mem" stm:"memory"` 15 Metrics documentMetrics `bson:"metrics" stm:"metrics"` 16 ExtraInfo documentExtraInfo `bson:"extra_info" stm:"extra_info"` 17 Asserts documentAsserts `bson:"asserts" stm:"asserts"` 18 Transactions *documentTransactions `bson:"transactions" stm:"txn"` // mongod in 3.6.3+ and on mongos in 4.2+ 19 GlobalLock *documentGlobalLock `bson:"globalLock" stm:"global_lock"` 20 Tcmalloc *documentTCMallocStatus `bson:"tcmalloc" stm:"tcmalloc"` 21 Locks *documentLocks `bson:"locks" stm:"locks"` 22 WiredTiger *documentWiredTiger `bson:"wiredTiger" stm:"wiredtiger"` 23 Repl interface{} `bson:"repl"` 24 } 25 26 type ( 27 // https://www.mongodb.com/docs/manual/reference/command/serverStatus/#opcounters 28 documentOpCounters struct { 29 Insert int64 `bson:"insert" stm:"insert"` 30 Query int64 `bson:"query" stm:"query"` 31 Update int64 `bson:"update" stm:"update"` 32 Delete int64 `bson:"delete" stm:"delete"` 33 GetMore int64 `bson:"getmore" stm:"getmore"` 34 Command int64 `bson:"command" stm:"command"` 35 } 36 // https://www.mongodb.com/docs/manual/reference/command/serverStatus/#oplatencies 37 documentOpLatencies struct { 38 Reads documentLatencyStats `bson:"reads" stm:"reads"` 39 Writes documentLatencyStats `bson:"writes" stm:"writes"` 40 Commands documentLatencyStats `bson:"commands" stm:"commands"` 41 } 42 // https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#latencystats-document 43 documentLatencyStats struct { 44 Latency int64 `bson:"latency" stm:"latency"` 45 Ops int64 `bson:"ops" stm:"ops"` 46 } 47 // https://www.mongodb.com/docs/manual/reference/command/serverStatus/#connections 48 documentConnections struct { 49 Current int64 `bson:"current" stm:"current"` 50 Available int64 `bson:"available" stm:"available"` 51 TotalCreated int64 `bson:"totalCreated" stm:"total_created"` 52 Active *int64 `bson:"active" stm:"active"` 53 Threaded *int64 `bson:"threaded" stm:"threaded"` 54 ExhaustIsMaster *int64 `bson:"exhaustIsMaster" stm:"exhaust_is_master"` 55 ExhaustHello *int64 `bson:"exhaustHello" stm:"exhaust_hello"` 56 AwaitingTopologyChanges *int64 `bson:"awaitingTopologyChanges" stm:"awaiting_topology_changes"` 57 } 58 // https://www.mongodb.com/docs/manual/reference/command/serverStatus/#network 59 documentNetwork struct { 60 BytesIn int64 `bson:"bytesIn" stm:"bytes_in"` 61 BytesOut int64 `bson:"bytesOut" stm:"bytes_out"` 62 NumRequests int64 `bson:"numRequests" stm:"requests"` 63 NumSlowDNSOperations *int64 `bson:"numSlowDNSOperations" stm:"slow_dns_operations"` // 4.4+ 64 NumSlowSSLOperations *int64 `bson:"numSlowSSLOperations" stm:"slow_ssl_operations"` // 4.4+ 65 } 66 // https://www.mongodb.com/docs/manual/reference/command/serverStatus/#mem 67 documentMemory struct { 68 Resident int64 `bson:"resident" stm:"resident,1048576,1"` 69 Virtual int64 `bson:"virtual" stm:"virtual,1048576,1"` 70 } 71 // https://www.mongodb.com/docs/manual/reference/command/serverStatus/#extra_info 72 documentExtraInfo struct { 73 PageFaults int64 `bson:"page_faults" stm:"page_faults"` 74 } 75 // Values: 76 // - mongodb: https://github.com/mongodb/mongo/blob/54e1be7d98aa154e1676d6d652b4d2d1a1073b07/src/mongo/util/tcmalloc_server_status_section.cpp#L88 77 // - tcmalloc: https://github.com/google/tcmalloc/blob/927c1433141daa1f0bcf920e6d71bf64795cc2c2/tcmalloc/global_stats.cc#L582 78 // formattedString: 79 // - https://github.com/google/tcmalloc/blob/master/docs/stats.md 80 // - https://github.com/google/tcmalloc/blob/927c1433141daa1f0bcf920e6d71bf64795cc2c2/tcmalloc/global_stats.cc#L208 81 documentTCMallocStatus struct { 82 Generic *struct { 83 CurrentAllocatedBytes int64 `bson:"current_allocated_bytes" stm:"current_allocated_bytes"` 84 HeapSize int64 `bson:"heap_size" stm:"heap_size"` 85 } `bson:"generic" stm:"generic"` 86 Tcmalloc *struct { 87 PageheapFreeBytes int64 `bson:"pageheap_free_bytes" stm:"pageheap_free_bytes"` 88 PageheapUnmappedBytes int64 `bson:"pageheap_unmapped_bytes" stm:"pageheap_unmapped_bytes"` 89 MaxTotalThreadCacheBytes int64 `bson:"max_total_thread_cache_bytes" stm:"max_total_thread_cache_bytes"` 90 CurrentTotalThreadCacheBytes int64 `bson:"current_total_thread_cache_bytes" stm:"current_total_thread_cache_bytes"` 91 TotalFreeBytes int64 `bson:"total_free_bytes" stm:"total_free_bytes"` 92 CentralCacheFreeBytes int64 `bson:"central_cache_free_bytes" stm:"central_cache_free_bytes"` 93 TransferCacheFreeBytes int64 `bson:"transfer_cache_free_bytes" stm:"transfer_cache_free_bytes"` 94 ThreadCacheFreeBytes int64 `bson:"thread_cache_free_bytes" stm:"thread_cache_free_bytes"` 95 AggressiveMemoryDecommit int64 `bson:"aggressive_memory_decommit" stm:"aggressive_memory_decommit"` 96 PageheapCommittedBytes int64 `bson:"pageheap_committed_bytes" stm:"pageheap_committed_bytes"` 97 PageheapScavengeBytes int64 `bson:"pageheap_scavenge_bytes" stm:"pageheap_scavenge_bytes"` 98 PageheapCommitCount int64 `bson:"pageheap_commit_count" stm:"pageheap_commit_count"` 99 PageheapTotalCommitBytes int64 `bson:"pageheap_total_commit_bytes" stm:"pageheap_total_commit_bytes"` 100 PageheapDecommitCount int64 `bson:"pageheap_decommit_count" stm:"pageheap_decommit_count"` 101 PageheapTotalDecommitBytes int64 `bson:"pageheap_total_decommit_bytes" stm:"pageheap_total_decommit_bytes"` 102 PageheapReserveCount int64 `bson:"pageheap_reserve_count" stm:"pageheap_reserve_count"` 103 PageheapTotalReserveBytes int64 `bson:"pageheap_total_reserve_bytes" stm:"pageheap_total_reserve_bytes"` 104 SpinlockTotalDelayNs int64 `bson:"spinlock_total_delay_ns" stm:"spinlock_total_delay_ns"` 105 } `bson:"tcmalloc" stm:""` 106 } 107 // https://www.mongodb.com/docs/manual/reference/command/serverStatus/#metrics 108 documentMetrics struct { 109 Cursor struct { 110 TotalOpened *int64 `bson:"totalOpened" stm:"total_opened"` 111 TimedOut *int64 `bson:"timedOut" stm:"timed_out"` 112 Open struct { 113 NoTimeout *int64 `bson:"noTimeout" stm:"no_timeout"` 114 Total *int64 `bson:"total" stm:"total"` 115 } `bson:"open" stm:"open"` 116 Lifespan *struct { 117 GreaterThanOrEqual10Minutes int64 `bson:"greaterThanOrEqual10Minutes" stm:"greater_than_or_equal_10_minutes"` 118 LessThan10Minutes int64 `bson:"lessThan10Minutes" stm:"less_than_10_minutes"` 119 LessThan15Seconds int64 `bson:"lessThan15Seconds" stm:"less_than_15_seconds"` 120 LessThan1Minute int64 `bson:"lessThan1Minute" stm:"less_than_1_minute"` 121 LessThan1Second int64 `bson:"lessThan1Second" stm:"less_than_1_second"` 122 LessThan30Seconds int64 `bson:"lessThan30Seconds" stm:"less_than_30_seconds"` 123 LessThan5Seconds int64 `bson:"lessThan5Seconds" stm:"less_than_5_seconds"` 124 } `bson:"lifespan" stm:"lifespan"` 125 } `bson:"cursor" stm:"cursor"` 126 Document struct { 127 Deleted int64 `bson:"deleted" stm:"deleted"` 128 Inserted int64 `bson:"inserted" stm:"inserted"` 129 Returned int64 `bson:"returned" stm:"returned"` 130 Updated int64 `bson:"updated" stm:"updated"` 131 } `bson:"document" stm:"document"` 132 QueryExecutor struct { 133 Scanned int64 `bson:"scanned" stm:"scanned"` 134 ScannedObjects int64 `bson:"scannedObjects" stm:"scanned_objects"` 135 } `bson:"queryExecutor" stm:"query_executor"` 136 } 137 // https://www.mongodb.com/docs/manual/reference/command/serverStatus/#asserts 138 documentAsserts struct { 139 Regular int64 `bson:"regular" stm:"regular"` 140 Warning int64 `bson:"warning" stm:"warning"` 141 Msg int64 `bson:"msg" stm:"msg"` 142 User int64 `bson:"user" stm:"user"` 143 Tripwire int64 `bson:"tripwire" stm:"tripwire"` 144 Rollovers int64 `bson:"rollovers" stm:"rollovers"` 145 } 146 // https://www.mongodb.com/docs/manual/reference/command/serverStatus/#transactions 147 documentTransactions struct { 148 CurrentActive *int64 `bson:"currentActive" stm:"active"` // mongod in 4.0.2+ and mongos in 4.2.1+ 149 CurrentInactive *int64 `bson:"currentInactive" stm:"inactive"` // mongod in 4.0.2+ and mongos in 4.2.1+ 150 CurrentOpen *int64 `bson:"currentOpen" stm:"open"` // mongod in 4.0.2+ and mongos in 4.2.1+ 151 CurrentPrepared *int64 `bson:"currentPrepared" stm:"prepared"` // 4.2+ mongod only 152 TotalAborted *int64 `bson:"totalAborted" stm:"total_aborted"` // mongod in 4.0.2+ and mongos in 4.2+ 153 TotalCommitted *int64 `bson:"totalCommitted" stm:"total_committed"` // mongod in 4.0.2+ and mongos in 4.2+ 154 TotalStarted *int64 `bson:"totalStarted" stm:"total_started"` // mongod in 4.0.2+ and mongos in 4.2+ 155 TotalPrepared *int64 `bson:"totalPrepared" stm:"total_prepared"` // mongod in 4.0.2+ and mongos in 4.2+ 156 CommitTypes *documentTransactionsCommitTypes `bson:"commitTypes" stm:"commit_types"` // mongos only 157 } 158 // https://www.mongodb.com/docs/manual/reference/command/serverStatus/#mongodb-serverstatus-serverstatus.transactions.commitTypes 159 documentTransactionsCommitTypes struct { 160 NoShards documentTransactionsCommitType `bson:"noShards" stm:"no_shards"` 161 SingleShard documentTransactionsCommitType `bson:"singleShard" stm:"single_shard"` 162 SingleWriteShard documentTransactionsCommitType `bson:"singleWriteShard" stm:"single_write_shard"` 163 ReadOnly documentTransactionsCommitType `bson:"readOnly" stm:"read_only"` 164 TwoPhaseCommit documentTransactionsCommitType `bson:"twoPhaseCommit" stm:"two_phase_commit"` 165 RecoverWithToken documentTransactionsCommitType `bson:"recoverWithToken" stm:"recover_with_token"` 166 } 167 documentTransactionsCommitType struct { 168 Initiated int64 `json:"initiated" stm:"initiated"` 169 Successful int64 `json:"successful" stm:"successful"` 170 SuccessfulDurationMicros int64 `json:"successfulDurationMicros" stm:"successful_duration_micros"` 171 } 172 // https://www.mongodb.com/docs/manual/reference/command/serverStatus/#globallock 173 documentGlobalLock struct { 174 CurrentQueue *struct { 175 Readers int64 `bson:"readers" stm:"readers"` 176 Writers int64 `bson:"writers" stm:"writers"` 177 } `bson:"currentQueue" stm:"current_queue"` 178 ActiveClients *struct { 179 Readers int64 `bson:"readers" stm:"readers"` 180 Writers int64 `bson:"writers" stm:"writers"` 181 } `bson:"activeClients" stm:"active_clients"` 182 } 183 // https://www.mongodb.com/docs/manual/reference/command/serverStatus/#mongodb-serverstatus-serverstatus.locks 184 documentLocks struct { 185 Global *documentLockType `bson:"Global" stm:"global"` 186 Database *documentLockType `bson:"Database" stm:"database"` 187 Collection *documentLockType `bson:"Collection" stm:"collection"` 188 Mutex *documentLockType `bson:"Mutex" stm:"mutex"` 189 Metadata *documentLockType `bson:"Metadata" stm:"metadata"` 190 Oplog *documentLockType `bson:"oplog" stm:"oplog"` 191 } 192 documentLockType struct { 193 AcquireCount documentLockModes `bson:"acquireCount" stm:"acquire"` 194 } 195 documentLockModes struct { 196 Shared int64 `bson:"R" stm:"shared"` 197 Exclusive int64 `bson:"W" stm:"exclusive"` 198 IntentShared int64 `bson:"r" stm:"intent_shared"` 199 IntentExclusive int64 `bson:"w" stm:"intent_exclusive"` 200 } 201 // https://www.mongodb.com/docs/manual/reference/command/serverStatus/#wiredtiger 202 documentWiredTiger struct { 203 ConcurrentTransaction struct { 204 Write struct { 205 Out int `bson:"out" stm:"out"` 206 Available int `bson:"available" stm:"available"` 207 } `bson:"write" stm:"write"` 208 Read struct { 209 Out int `bson:"out" stm:"out"` 210 Available int `bson:"available" stm:"available"` 211 } `bson:"read" stm:"read"` 212 } `bson:"concurrentTransactions" stm:"concurrent_txn"` 213 Cache struct { 214 BytesCurrentlyInCache int `bson:"bytes currently in the cache" stm:"currently_in_cache_bytes"` 215 MaximumBytesConfigured int `bson:"maximum bytes configured" stm:"maximum_configured_bytes"` 216 TrackedDirtyBytesInCache int `bson:"tracked dirty bytes in the cache" stm:"tracked_dirty_in_the_cache_bytes"` 217 UnmodifiedPagesEvicted int `bson:"unmodified pages evicted" stm:"unmodified_evicted_pages"` 218 ModifiedPagesEvicted int `bson:"modified pages evicted" stm:"modified_evicted_pages"` 219 PagesReadIntoCache int `bson:"pages read into cache" stm:"read_into_cache_pages"` 220 PagesWrittenFromCache int `bson:"pages written from cache" stm:"written_from_cache_pages"` 221 } `bson:"cache" stm:"cache"` 222 } 223 ) 224 225 // https://www.mongodb.com/docs/manual/reference/command/dbStats/ 226 type documentDBStats struct { 227 Collections int64 `bson:"collections"` 228 Views int64 `bson:"views"` 229 Indexes int64 `bson:"indexes"` 230 Objects int64 `bson:"objects"` 231 DataSize int64 `bson:"dataSize"` 232 IndexSize int64 `bson:"indexSize"` 233 StorageSize int64 `bson:"storageSize"` 234 } 235 236 // https://www.mongodb.com/docs/manual/reference/command/replSetGetStatus/ 237 type documentReplSetStatus struct { 238 Date time.Time `bson:"date"` 239 Members []documentReplSetMember `bson:"members"` 240 } 241 242 type ( 243 documentReplSetMember struct { 244 Name string `bson:"name"` 245 Self *bool `bson:"self"` 246 State int `bson:"state"` 247 Health int `bson:"health"` 248 OptimeDate time.Time `bson:"optimeDate"` 249 LastHeartbeat *time.Time `bson:"lastHeartbeat"` 250 LastHeartbeatRecv *time.Time `bson:"lastHeartbeatRecv"` 251 PingMs *int64 `bson:"pingMs"` 252 Uptime int64 `bson:"uptime"` 253 } 254 ) 255 256 type documentAggrResults struct { 257 Bool bool `bson:"_id"` 258 Count int64 `bson:"count"` 259 } 260 261 type ( 262 documentAggrResult struct { 263 True int64 264 False int64 265 } 266 ) 267 268 type documentPartitionedResult struct { 269 Partitioned int64 270 UnPartitioned int64 271 } 272 273 type documentShardNodesResult struct { 274 ShardAware int64 275 ShardUnaware int64 276 }