Documentation ¶
Index ¶
- Constants
- Variables
- func GetAllServerURIs(shards []ShardDoc, connString connstring.ConnString) ([]string, error)
- func GetAllShardURIs(shards []ShardDoc, connString connstring.ConnString) ([]string, error)
- func GetClusterSummary(client *mongo.Client) string
- func GetIndexSuggestion(explain ExplainCommand, cardList []CardinalityCount) gox.OrderedMap
- func GetKeys(document bson.D, _range ...bool) []string
- func GetOplogStats(client *mongo.Client) bson.M
- func GetServerInfo(client *mongo.Client) bson.M
- func IsMaster(client *mongo.Client) (bson.M, error)
- func ListDatabaseNames(client *mongo.Client) ([]string, error)
- func MongoPipeline(str string) mongo.Pipeline
- func NewMongoClient(uri string, files ...string) (*mongo.Client, error)
- func ParseURI(uri string) (connstring.ConnString, error)
- func PrintBSON(filename string) error
- func RunAdminCommand(client *mongo.Client, command string) (bson.M, error)
- func RunCommandOnDB(client *mongo.Client, command string, db string) (bson.M, error)
- func ToFloat64(num interface{}) float64
- func ToInt64(num interface{}) int64
- type AccessesDoc
- type Cardinality
- type CardinalityCount
- type CardinalitySummary
- type ChangeStream
- type ChartDataPoint
- type CollectionIndexes
- type DBStats
- type DatabaseInfo
- func (dbi *DatabaseInfo) GetAllDatabasesInfo(client *mongo.Client) ([]bson.M, error)
- func (dbi *DatabaseInfo) GetLogs() []string
- func (dbi *DatabaseInfo) SetNumberConnections(conns int)
- func (dbi *DatabaseInfo) SetRedaction(redaction bool)
- func (dbi *DatabaseInfo) SetVerbose(verbose bool)
- func (dbi *DatabaseInfo) SetVeryVerbose(vv bool)
- type Explain
- type ExplainCommand
- type ExplainSummary
- type IndexScore
- type IndexStatsDoc
- type Indexes
- func (ix *Indexes) CreateIndexes() error
- func (ix *Indexes) GetIndexes() (map[string]CollectionIndexes, error)
- func (ix *Indexes) GetIndexesFromCollection(collection *mongo.Collection) []IndexStatsDoc
- func (ix *Indexes) GetIndexesFromDB(dbName string) (CollectionIndexes, error)
- func (ix *Indexes) Print()
- func (ix *Indexes) PrintIndexesOf(indexesMap map[string]CollectionIndexes)
- func (ix *Indexes) Save() error
- func (ix *Indexes) SetDBName(dbName string)
- func (ix *Indexes) SetFilename(filename string)
- func (ix *Indexes) SetIndexesMap(indexesMap map[string]CollectionIndexes)
- func (ix *Indexes) SetIndexesMapFromFile(filename string) error
- func (ix *Indexes) SetNoColor(nocolor bool)
- func (ix *Indexes) SetVerbose(verbose bool)
- type KeyholeInfo
- type LogInfo
- func (li *LogInfo) Analyze(filename string) (string, error)
- func (li *LogInfo) AnalyzeFile(filename string, redact bool) (string, error)
- func (li *LogInfo) Parse(reader *bufio.Reader, counts ...int) error
- func (li *LogInfo) ParseLog(str string) (LogStats, error)
- func (li *LogInfo) ParseLogv2(str string) (LogStats, error)
- func (li *LogInfo) SetCollscan(collscan bool)
- func (li *LogInfo) SetKeyholeInfo(keyholeInfo *KeyholeInfo)
- func (li *LogInfo) SetRegexPattern(regex string)
- func (li *LogInfo) SetSilent(silent bool)
- func (li *LogInfo) SetVerbose(verbose bool)
- type LogStats
- type MongoCluster
- func (mc *MongoCluster) GetClusterInfo() (bson.M, error)
- func (mc *MongoCluster) SetConnString(connString connstring.ConnString)
- func (mc *MongoCluster) SetFilename(filename string)
- func (mc *MongoCluster) SetKeyholeInfo(keyholeInfo *KeyholeInfo)
- func (mc *MongoCluster) SetNumberConnections(conns int)
- func (mc *MongoCluster) SetRedaction(redaction bool)
- func (mc *MongoCluster) SetVerbose(verbose bool)
- func (mc *MongoCluster) SetVeryVerbose(vv bool)
- type OpPerformanceDoc
- type OplogStats
- type QueryExplainer
- func (qe *QueryExplainer) Explain() (ExplainSummary, error)
- func (qe *QueryExplainer) GetExplainDetails(doc bson.M) ExplainSummary
- func (qe *QueryExplainer) GetFilter() bson.D
- func (qe *QueryExplainer) GetIndexesScores(keys []string) []IndexScore
- func (qe *QueryExplainer) GetSummary(summary ExplainSummary) string
- func (qe *QueryExplainer) ReadQueryShape(buffer []byte) error
- func (qe *QueryExplainer) SetVerbose(verbose bool)
- type Redactor
- type ShardDoc
- type SlowOps
- type StageStats
- type UsageDoc
- type WiredTigerCache
Constants ¶
const COLLSCAN = "COLLSCAN"
COLLSCAN constance
const REPLICA = "replica"
REPLICA set
const SHARDED = "sharded"
SHARDED cluster
const STANDALONE = "standalone"
STANDALONE cluster
Variables ¶
var ExamplesCollection = "__examples"
ExamplesCollection default test colection
var KeyholeDB = "_KEYHOLE_88800"
KeyholeDB default database
Functions ¶
func GetAllServerURIs ¶ added in v1.0.1
func GetAllServerURIs(shards []ShardDoc, connString connstring.ConnString) ([]string, error)
GetAllServerURIs returns URIs of all mongo servers
func GetAllShardURIs ¶ added in v1.0.1
func GetAllShardURIs(shards []ShardDoc, connString connstring.ConnString) ([]string, error)
GetAllShardURIs returns URIs of all replicas
func GetClusterSummary ¶
GetClusterSummary returns cluster summary
func GetIndexSuggestion ¶ added in v1.0.1
func GetIndexSuggestion(explain ExplainCommand, cardList []CardinalityCount) gox.OrderedMap
GetIndexSuggestion returns a recommended index by cardinalities index follows a principle of equality, sort, rnage
func GetOplogStats ¶ added in v1.0.1
GetOplogStats returns oplog stats
func GetServerInfo ¶
GetServerInfo gets mongo server information
func ListDatabaseNames ¶
ListDatabaseNames gets all database names
func MongoPipeline ¶
MongoPipeline gets aggregation pipeline from a string
func NewMongoClient ¶
NewMongoClient new mongo client
func ParseURI ¶ added in v1.0.1
func ParseURI(uri string) (connstring.ConnString, error)
ParseURI checks if password is included
func RunAdminCommand ¶
RunAdminCommand executes admin Command
func RunCommandOnDB ¶
RunCommandOnDB execute admin Command at given database
Types ¶
type AccessesDoc ¶ added in v1.1.2
type AccessesDoc struct { Ops int `json:"ops" bson:"ops"` Since time.Time `json:"since" bson:"since"` }
AccessesDoc - accessss
type Cardinality ¶
type Cardinality struct {
// contains filtered or unexported fields
}
Cardinality -
func NewCardinality ¶
func NewCardinality(client *mongo.Client) *Cardinality
NewCardinality returns cardinality constructor
func (*Cardinality) GetCardinalityArray ¶ added in v1.0.1
func (card *Cardinality) GetCardinalityArray(database string, collection string, keys ...[]string) (CardinalitySummary, error)
GetCardinalityArray returns cardinality list
func (*Cardinality) GetSummary ¶ added in v1.0.1
func (card *Cardinality) GetSummary(summary CardinalitySummary) string
GetSummary get summary of cardinality
type CardinalityCount ¶ added in v1.0.1
CardinalityCount stores cardinality counts
type CardinalitySummary ¶ added in v1.0.1
type CardinalitySummary struct { SampledCount int64 List []CardinalityCount }
CardinalitySummary stores Cardinality summary
type ChangeStream ¶ added in v1.0.1
type ChangeStream struct {
// contains filtered or unexported fields
}
ChangeStream defines what to watch? client, database or collection
func NewChangeStream ¶ added in v1.0.1
func NewChangeStream() *ChangeStream
NewChangeStream gets a new ChangeStream
func (*ChangeStream) SetCollection ¶ added in v1.0.1
func (cs *ChangeStream) SetCollection(collection string)
SetCollection sets collection
func (*ChangeStream) SetDatabase ¶ added in v1.0.1
func (cs *ChangeStream) SetDatabase(database string)
SetDatabase sets database
func (*ChangeStream) SetPipeline ¶ added in v1.0.1
func (cs *ChangeStream) SetPipeline(pipeline []bson.D)
SetPipeline sets pipeline
func (*ChangeStream) SetPipelineString ¶ added in v1.0.1
func (cs *ChangeStream) SetPipelineString(pipe string)
SetPipelineString sets pipeline string
func (*ChangeStream) Watch ¶ added in v1.0.1
func (cs *ChangeStream) Watch(client *mongo.Client, cb callback)
Watch prints oplogs in JSON format
type ChartDataPoint ¶ added in v1.0.1
type ChartDataPoint struct {
// contains filtered or unexported fields
}
ChartDataPoint has chart data points key/value
type CollectionIndexes ¶
type CollectionIndexes map[string][]IndexStatsDoc
CollectionIndexes store index stats in a map
type DBStats ¶
type DBStats struct { DB string `json:"db" bson:"db"` DataSize int `json:"dataSize" bson:"dataSize"` IndexSize int `json:"indexSize" bson:"indexSize"` Objects int `json:"objects" bson:"objects"` }
DBStats contains info from db.stats()
type DatabaseInfo ¶
type DatabaseInfo struct {
// contains filtered or unexported fields
}
DatabaseInfo stores struct
func (*DatabaseInfo) GetAllDatabasesInfo ¶
GetAllDatabasesInfo gets all db info
func (*DatabaseInfo) SetNumberConnections ¶
func (dbi *DatabaseInfo) SetNumberConnections(conns int)
SetNumberConnections set # of conns
func (*DatabaseInfo) SetRedaction ¶
func (dbi *DatabaseInfo) SetRedaction(redaction bool)
SetRedaction sets redaction
func (*DatabaseInfo) SetVerbose ¶
func (dbi *DatabaseInfo) SetVerbose(verbose bool)
SetVerbose sets verbosity
func (*DatabaseInfo) SetVeryVerbose ¶
func (dbi *DatabaseInfo) SetVeryVerbose(vv bool)
SetVeryVerbose set very verbose
type Explain ¶ added in v1.0.1
type Explain struct {
// contains filtered or unexported fields
}
Explain stores explain object info
func (*Explain) ExecuteAllPlans ¶ added in v1.0.1
ExecuteAllPlans calls queryPlanner and cardinality
func (*Explain) PrintExplainResults ¶ added in v1.0.1
PrintExplainResults prints explain results
func (*Explain) SetVerbose ¶ added in v1.0.1
SetVerbose sets verbosity
type ExplainCommand ¶ added in v1.0.1
type ExplainCommand struct { Collection string `bson:"find"` Filter bson.D `bson:"filter"` Sort bson.D `bson:"sort,omitempty"` Hint bson.D `bson:"hint,omitempty"` Group string `bson:"group,omitempty"` }
ExplainCommand stores explain document
type ExplainSummary ¶ added in v1.0.1
type ExplainSummary struct { ShardName string `json:"shardName"` ExecutionStats StageStats `json:"executionStats"` AllPlansExecutionStats []StageStats `json:"allPlansExecution"` }
ExplainSummary stores explain summary
type IndexScore ¶ added in v1.0.1
type IndexScore struct { Index gox.OrderedMap `json:"index"` Score float64 `json:"score"` }
IndexScore keeps index score
type IndexStatsDoc ¶
type IndexStatsDoc struct { Background bool `json:"background" bson:"background"` Collation bson.D `json:"collation" bson:"collation"` EffectiveKey string `json:"effectivekey" bson:"effectivekey"` ExpireAfterSeconds int32 `json:"expireafterseconds" bson:"expireafterseconds"` Fields []string `json:"fields" bson:"fields"` IndexKey bson.D `json:"indexkey" bson:"indexkey"` IsDupped bool `json:"isdupped" bson:"isdupped"` IsShardKey bool `json:"isshardkey" bson:"isshardkey"` Key string `json:"key" bson:"key"` Name string `json:"name" bson:"name"` PartialFilterExpression bson.D `json:"partialfilterexpression" bson:"partialfilterexpression"` Sparse bool `json:"sparse" bson:"sparse"` TotalOps int `json:"totalops" bson:"totalops"` Unique bool `json:"unique" bson:"unique"` Usage []UsageDoc `json:"usage" bson:"usage"` Version int32 `json:"version" bson:"version"` }
IndexStatsDoc -
type Indexes ¶
type Indexes struct {
// contains filtered or unexported fields
}
Indexes holder indexes reader struct
func NewIndexes ¶
NewIndexes establish seeding parameters
func (*Indexes) CreateIndexes ¶
CreateIndexes creates indexes
func (*Indexes) GetIndexes ¶
func (ix *Indexes) GetIndexes() (map[string]CollectionIndexes, error)
GetIndexes list all indexes of collections of databases
func (*Indexes) GetIndexesFromCollection ¶
func (ix *Indexes) GetIndexesFromCollection(collection *mongo.Collection) []IndexStatsDoc
GetIndexesFromCollection gets indexes from a collection
func (*Indexes) GetIndexesFromDB ¶
func (ix *Indexes) GetIndexesFromDB(dbName string) (CollectionIndexes, error)
GetIndexesFromDB list all indexes of collections of a database
func (*Indexes) PrintIndexesOf ¶
func (ix *Indexes) PrintIndexesOf(indexesMap map[string]CollectionIndexes)
PrintIndexesOf prints indexes
func (*Indexes) SetFilename ¶
SetFilename sets output file name
func (*Indexes) SetIndexesMap ¶
func (ix *Indexes) SetIndexesMap(indexesMap map[string]CollectionIndexes)
SetIndexesMap sets indexes map
func (*Indexes) SetIndexesMapFromFile ¶
SetIndexesMapFromFile File sets indexes map from a file
func (*Indexes) SetNoColor ¶
SetNoColor set nocolor flag
func (*Indexes) SetVerbose ¶
SetVerbose sets verbose level
type KeyholeInfo ¶
KeyholeInfo stores keyhole info
func NewKeyholeInfo ¶
func NewKeyholeInfo(version string, params string) *KeyholeInfo
NewKeyholeInfo returns KeyholeInfo
type LogInfo ¶ added in v1.0.1
type LogInfo struct { OpsPatterns []OpPerformanceDoc `bson:"opespatterns"` OutputFilename string SlowOps []SlowOps `bson:"slowops"` KeyholeInfo *KeyholeInfo `bson:"keyhole"` // contains filtered or unexported fields }
LogInfo keeps loginfo struct
func (*LogInfo) AnalyzeFile ¶ added in v1.0.1
AnalyzeFile analyze logs from a file
func (*LogInfo) ParseLogv2 ¶ added in v1.0.1
ParseLogv2 - parses text message before v4.4
func (*LogInfo) SetCollscan ¶ added in v1.0.1
SetCollscan -
func (*LogInfo) SetKeyholeInfo ¶
func (li *LogInfo) SetKeyholeInfo(keyholeInfo *KeyholeInfo)
SetKeyholeInfo sets keyhole version
func (*LogInfo) SetRegexPattern ¶ added in v1.0.1
SetRegexPattern sets regex patthen
func (*LogInfo) SetVerbose ¶ added in v1.0.1
SetVerbose -
type LogStats ¶ added in v1.0.1
type LogStats struct {
// contains filtered or unexported fields
}
LogStats log stats structure
type MongoCluster ¶ added in v1.1.0
type MongoCluster struct { KeyholeInfo *KeyholeInfo // contains filtered or unexported fields }
MongoCluster holds mongo cluster info
func NewMongoCluster ¶ added in v1.1.0
func NewMongoCluster(client *mongo.Client) *MongoCluster
NewMongoCluster server info struct
func (*MongoCluster) GetClusterInfo ¶ added in v1.1.0
func (mc *MongoCluster) GetClusterInfo() (bson.M, error)
GetClusterInfo -
func (*MongoCluster) SetConnString ¶ added in v1.5.1
func (mc *MongoCluster) SetConnString(connString connstring.ConnString)
SetConnString set connString object
func (*MongoCluster) SetFilename ¶ added in v1.4.2
func (mc *MongoCluster) SetFilename(filename string)
SetFilename sets output file name
func (*MongoCluster) SetKeyholeInfo ¶
func (mc *MongoCluster) SetKeyholeInfo(keyholeInfo *KeyholeInfo)
SetKeyholeInfo sets keyhole version
func (*MongoCluster) SetNumberConnections ¶
func (mc *MongoCluster) SetNumberConnections(conns int)
SetNumberConnections set # of conns
func (*MongoCluster) SetRedaction ¶
func (mc *MongoCluster) SetRedaction(redaction bool)
SetRedaction sets redact
func (*MongoCluster) SetVerbose ¶ added in v1.1.0
func (mc *MongoCluster) SetVerbose(verbose bool)
SetVerbose -
func (*MongoCluster) SetVeryVerbose ¶
func (mc *MongoCluster) SetVeryVerbose(vv bool)
SetVeryVerbose -
type OpPerformanceDoc ¶ added in v1.1.3
type OpPerformanceDoc struct { Command string `bson:"command"` // count, delete, find, remove, and update Count int `bson:"count"` // number of ops Filter string `bson:"filter"` // query pattern MaxMilli int `bson:"maxmilli"` // max millisecond Namespace string `bson:"ns"` // database.collectin Scan string `bson:"scan"` // COLLSCAN TotalMilli int `bson:"totalmilli"` // total milliseconds Index string `bson:"index"` // index used }
OpPerformanceDoc stores performance data
type OplogStats ¶ added in v1.0.1
OplogStats stores oplog stats
type QueryExplainer ¶ added in v1.0.1
type QueryExplainer struct { ExplainCmd ExplainCommand `bson:"explain"` NameSpace string // contains filtered or unexported fields }
QueryExplainer stores query analyzer info
func NewQueryExplainer ¶ added in v1.0.1
func NewQueryExplainer(client *mongo.Client) *QueryExplainer
NewQueryExplainer returns QueryExplainer
func (*QueryExplainer) Explain ¶ added in v1.0.1
func (qe *QueryExplainer) Explain() (ExplainSummary, error)
Explain explains query plans
func (*QueryExplainer) GetExplainDetails ¶ added in v1.0.1
func (qe *QueryExplainer) GetExplainDetails(doc bson.M) ExplainSummary
GetExplainDetails returns summary from a doc
func (*QueryExplainer) GetFilter ¶ added in v1.0.1
func (qe *QueryExplainer) GetFilter() bson.D
GetFilter sets verbosity
func (*QueryExplainer) GetIndexesScores ¶ added in v1.0.1
func (qe *QueryExplainer) GetIndexesScores(keys []string) []IndexScore
GetIndexesScores returns a list of indexes scores
func (*QueryExplainer) GetSummary ¶ added in v1.0.1
func (qe *QueryExplainer) GetSummary(summary ExplainSummary) string
GetSummary get summary of explain executionStats
func (*QueryExplainer) ReadQueryShape ¶ added in v1.0.1
func (qe *QueryExplainer) ReadQueryShape(buffer []byte) error
ReadQueryShape parses filter map
func (*QueryExplainer) SetVerbose ¶ added in v1.0.1
func (qe *QueryExplainer) SetVerbose(verbose bool)
SetVerbose sets verbosity
type Redactor ¶ added in v1.0.1
type Redactor struct {
// contains filtered or unexported fields
}
Redactor stores Redact struct
func (*Redactor) SetVerbose ¶ added in v1.0.1
SetVerbose sets verbosity
type ShardDoc ¶
type ShardDoc struct { ID string `json:"_id" bson:"_id"` Host string `json:"host" bson:"host"` State int `json:"state" bson:"state"` }
ShardDoc information
type StageStats ¶ added in v1.0.1
type StageStats struct { Level int Score float64 `json:"Score"` Stage string `json:"stage"` Filter *gox.OrderedMap `json:"filter"` KeyPattern *gox.OrderedMap `json:"keyPattern"` Advanced int32 `json:"advanced"` Works int32 `json:"works"` ExecTimeMillisEst int32 `json:"executionTimeMillisEstimate"` TotalKeysExamined int32 `json:"totalKeysExamined"` TotalDocsExamined int32 `json:"totalDocsExamined"` InputStages []StageStats `json:"inputStages"` }
StageStats stores stats for each stage
type UsageDoc ¶
type UsageDoc struct { Host string `json:"host"` Accesses AccessesDoc `json:"accesses"` }
UsageDoc -
type WiredTigerCache ¶ added in v1.0.1
type WiredTigerCache struct {
// contains filtered or unexported fields
}
WiredTigerCache stores wiredTiger cache structure
func NewWiredTigerCache ¶ added in v1.0.1
func NewWiredTigerCache(client *mongo.Client) *WiredTigerCache
NewWiredTigerCache returns *WiredTigerCache
func (*WiredTigerCache) GetAllDatabasesInfo ¶
func (wtc *WiredTigerCache) GetAllDatabasesInfo() error
GetAllDatabasesInfo returns db info
func (*WiredTigerCache) GetWiredTigerCacheData ¶ added in v1.0.1
func (wtc *WiredTigerCache) GetWiredTigerCacheData(w http.ResponseWriter, r *http.Request)
GetWiredTigerCacheData gets WT cache data
func (*WiredTigerCache) Handler ¶ added in v1.0.1
func (wtc *WiredTigerCache) Handler(w http.ResponseWriter, r *http.Request)
Handler supports resetful calls
func (*WiredTigerCache) Start ¶ added in v1.0.1
func (wtc *WiredTigerCache) Start()
Start starts a web server and a thread to collect caches
Source Files ¶
- cardinality.go
- change_streams.go
- command.go
- databases_info.go
- db_stats.go
- explain.go
- index_suggestion.go
- indexes.go
- keyhole_info.go
- log_parser.go
- loginfo.go
- logv2_parser.go
- mongo_client.go
- mongo_cluster.go
- oplog.go
- pipeline.go
- print_bson.go
- query_explainer.go
- redactor.go
- server_info.go
- shards.go
- utils.go
- wt_cache.go
- wt_html.go