mdb

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: Apache-2.0 Imports: 34 Imported by: 4

Documentation

Index

Constants

View Source
const COLLSCAN = "COLLSCAN"

COLLSCAN constance

View Source
const Replica = "replica"

Replica set

View Source
const Sharded = "sharded"

Sharded cluster

View Source
const Standalone = "standalone"

Standalone server

View Source
const (
	// TopologyConnectionError keyhole custom error codes
	TopologyConnectionError int = 20001
)

Variables

View Source
var CodeBlue = "\x1b[34;1m"

CodeBlue shows blue color

View Source
var CodeDefault = "\x1b[0m"

CodeDefault shows default color

View Source
var CodeGreen = "\x1b[32;1m"

CodeGreen shows green color

View Source
var CodeRed = "\x1b[31;1m"

CodeRed shows red color

View Source
var CodeYellow = "\x1b[33;1m"

CodeYellow shows yellow color

View Source
var ExamplesCollection = "__examples"

ExamplesCollection default test colection

View Source
var KeyholeDB = "_KEYHOLE_88800"

KeyholeDB default database

Functions

func DoesFileExist added in v1.0.6

func DoesFileExist(filename string) bool

DoesFileExist returns true if file exists

func GetAllServerURIs added in v1.0.1

func GetAllServerURIs(shards []Shard, connString connstring.ConnString) ([]string, error)

GetAllServerURIs returns URIs of all mongo servers

func GetAllShardURIs added in v1.0.1

func GetAllShardURIs(shards []Shard, connString connstring.ConnString) ([]string, error)

GetAllShardURIs returns URIs of all replicas

func GetClusterType added in v1.0.1

func GetClusterType(serverStatus ServerStatus) string

GetClusterType returns cluster type

func GetDatabaseNames added in v1.0.3

func GetDatabaseNames(client *mongo.Client) ([]string, error)

GetDatabaseNames gets all database names

func GetErrorCode added in v1.0.3

func GetErrorCode(err error) int

GetErrorCode gets error code for debug purpose

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 GetKeys added in v1.0.1

func GetKeys(document bson.D, _range ...bool) []string

GetKeys gets all fields of a odc as an array

func GetQueryParams added in v1.2.1

func GetQueryParams(connString connstring.ConnString, isConnectDirect bool) string

GetQueryParams returns partial connection string from ConnString

func IsDuplicateKeyError added in v1.0.3

func IsDuplicateKeyError(err error) bool

IsDuplicateKeyError check if error is from duplicate key

func IsUnauthorizedError added in v1.0.3

func IsUnauthorizedError(err error) bool

IsUnauthorizedError check Unauthorized error

func MongoPipeline

func MongoPipeline(str string) mongo.Pipeline

MongoPipeline gets aggregation pipeline from a string

func NewMongoClient

func NewMongoClient(uri string) (*mongo.Client, error)

NewMongoClient new mongo client

func OutputLogInOldFormat added in v1.0.8

func OutputLogInOldFormat(filename string) error

OutputLogInOldFormat view v4.4+ logs in old format

func ParseURI added in v1.0.1

func ParseURI(uri string) (connstring.ConnString, error)

ParseURI checks if password is included

func RunAdminCommand

func RunAdminCommand(client *mongo.Client, command string) (bson.M, error)

RunAdminCommand executes admin Command

func RunCommandOnDB

func RunCommandOnDB(client *mongo.Client, command string, db string) (bson.M, error)

RunCommandOnDB execute admin Command at given database

func SkipNamespace added in v1.0.4

func SkipNamespace(namespace string, namespaceMap map[string]bool) bool

SkipNamespace skips namespace

func SplitNamespace added in v1.0.4

func SplitNamespace(namespace string) (string, string)

SplitNamespace returns db, collection

func ToFloat64 added in v1.0.1

func ToFloat64(num interface{}) float64

ToFloat64 converts to float64

func ToInt added in v1.0.4

func ToInt(num interface{}) int

ToInt converts to int

func ToInt32 added in v1.0.4

func ToInt32(num interface{}) int32

ToInt32 converts to int32

func ToInt64 added in v1.0.1

func ToInt64(num interface{}) int64

ToInt64 converts to in64

Types

type Accesses added in v1.0.1

type Accesses struct {
	Ops   int       `json:"ops" bson:"ops"`
	Since time.Time `json:"since" bson:"since"`
}

Accesses stores index accesses

type BSONPrinter added in v1.0.1

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

BSONPrinter stores bson printer info

func NewBSONPrinter added in v1.0.1

func NewBSONPrinter(version string) *BSONPrinter

NewBSONPrinter returns BSONPrinter

func (*BSONPrinter) Print added in v1.0.1

func (p *BSONPrinter) Print(filename string) error

Print print summary or output json from bson

func (*BSONPrinter) SetNoColor added in v1.0.1

func (p *BSONPrinter) SetNoColor(nocolor bool)

SetNoColor set nocolor flag

type BuildInfo added in v1.0.1

type BuildInfo struct {
	GitVersion string   `bson:"gitVersion"`
	Modules    []string `bson:"modules"`
	Version    string   `bson:"version"`
}

BuildInfo stores build information

func GetBuildInfo added in v1.0.1

func GetBuildInfo(client *mongo.Client) (BuildInfo, error)

GetBuildInfo returns MongoDB build information

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

func (*Cardinality) SetVerbose

func (card *Cardinality) SetVerbose(verbose bool)

SetVerbose -

type CardinalityCount added in v1.0.1

type CardinalityCount struct {
	Field string
	Count int64
}

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 Chunk added in v1.0.1

type Chunk struct {
	Empty   int64  `bson:"empty"`
	Jumbo   int64  `bson:"jumbo"`
	Objects int64  `bson:"objects"`
	Shard   string `bson:"shard"`
	Size    int64  `bson:"size"`
	Total   int64  `bson:"total"`
}

Chunk stores chunk stats

type ClusterStats added in v1.0.1

type ClusterStats struct {
	BuildInfo        BuildInfo        `bson:"buildInfo"`
	CmdLineOpts      CmdLineOpts      `bson:"getCmdLineOpts"`
	Cluster          string           `bson:"cluster"`
	Databases        []Database       `bson:"databases"`
	Host             string           `bson:"host"`
	HostInfo         HostInfo         `bson:"hostInfo"`
	Logger           *gox.Logger      `bson:"keyhole"`
	OplogStats       OplogStats       `bson:"oplog"`
	Process          string           `bson:"process"`
	ReplSetGetStatus ReplSetGetStatus `bson:"replSetGetStatus"`
	ServerStatus     ServerStatus     `bson:"serverStatus"`
	Shards           []Shard          `bson:"shards"`
	Version          string           `bson:"version"`
	// contains filtered or unexported fields
}

ClusterStats keeps slow ops struct

func NewClusterStats added in v1.0.4

func NewClusterStats(signature string) *ClusterStats

NewClusterStats returns *ClusterStats

func (*ClusterStats) GetClusterShortSummary added in v1.0.1

func (p *ClusterStats) GetClusterShortSummary(client *mongo.Client) string

GetClusterShortSummary returns one line summary

func (*ClusterStats) GetClusterStats added in v1.0.1

func (p *ClusterStats) GetClusterStats(client *mongo.Client, connString connstring.ConnString) error

GetClusterStats collects cluster stats

func (*ClusterStats) GetClusterStatsSummary added in v1.0.1

func (p *ClusterStats) GetClusterStatsSummary(client *mongo.Client) error

GetClusterStatsSummary collects cluster stats

func (*ClusterStats) GetServersStatsSummary added in v1.0.1

func (p *ClusterStats) GetServersStatsSummary(shards []Shard, connString connstring.ConnString) ([]Shard, error)

GetServersStatsSummary returns cluster stats from all shards

func (*ClusterStats) GetShortSummary added in v1.0.1

func (p *ClusterStats) GetShortSummary() string

GetShortSummary returns a short summary

func (*ClusterStats) OutputBSON added in v1.0.1

func (p *ClusterStats) OutputBSON() (string, []byte, error)

OutputBSON writes bson data to a file

func (*ClusterStats) Print added in v1.0.1

func (p *ClusterStats) Print()

Print prints a cluster short summary

func (*ClusterStats) SetDBNames added in v1.1.7

func (p *ClusterStats) SetDBNames(dbNames []string)

SetDBNames sets redact

func (*ClusterStats) SetFastMode added in v1.2.1

func (p *ClusterStats) SetFastMode(fastMode bool)

SetFastMode sets fastMode mode

func (*ClusterStats) SetRedaction added in v1.0.1

func (p *ClusterStats) SetRedaction(redact bool)

SetRedaction sets redact

func (*ClusterStats) SetVerbose added in v1.0.1

func (p *ClusterStats) SetVerbose(verbose bool)

SetVerbose sets verbose mode

type CmdLineOpts added in v1.0.1

type CmdLineOpts struct {
	Argv   []string `bson:"argv"`
	Parsed bson.M   `bson:"parsed"`
}

CmdLineOpts stores build information

func GetCmdLineOpts added in v1.0.1

func GetCmdLineOpts(client *mongo.Client) (CmdLineOpts, error)

GetCmdLineOpts returns MongoDB build information

type Collection added in v1.0.1

type Collection struct {
	Chunks   []Chunk `bson:"chunks,truncate"`
	Document bson.M  `bson:"document,truncate"`
	Indexes  []Index `bson:"indexes,truncate"`
	Name     string  `bson:"name,truncate"`
	NS       string  `bson:"namespace,truncate"`
	Stats    struct {
		Count          int64   `bson:"count,truncate"`
		IndexDetails   bson.M  `bson:"indexDetails,truncate"`
		AvgObjSize     float64 `bson:"avgObjSize,truncate"`
		WiredTiger     bson.M  `bson:"wiredTiger,truncate"`
		IndexSizes     bson.M  `bson:"indexSizes,truncate"`
		Capped         bool    `bson:"capped,truncate"`
		TotalIndexSize int64   `bson:"totalIndexSize,truncate"`
		MaxSize        int64   `bson:"maxSize,truncate"`
		Nindexes       int64   `bson:"nindexes,truncate"`
		Shards         bson.M  `bson:"shards,truncate"`
		NS             string  `bson:"namespace,truncate"`
		Nchunks        int64   `bson:"nchunks,truncate"`
		Sharded        bool    `bson:"sharded,truncate"`
		Size           int64   `bson:"size,truncate"`
		StorageSize    int64   `bson:"storageSize,truncate"`
	} `bson:"stats"`
}

Collection stores struct

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 Database added in v1.0.1

type Database struct {
	Name        string       `bson:"name"`
	Collections []Collection `bson:"collections,truncate"`
	SizeOnDisk  int64        `bson:"sizeOnDisk,truncate"`
	Empty       bool         `bson:"empty,truncate"`
	Shards      bson.M       `bson:"shards,truncate"`
	Stats       struct {
		Raw         bson.M `bson:"raw,truncate"`
		Objects     int64  `bson:"objects,truncate"`
		IndexSize   int64  `bson:"indexSize,truncate"`
		FileSize    int64  `bson:"fileSize,truncate"`
		Indexes     int64  `bson:"indexes,truncate"`
		ScaleFactor int64  `bson:"scaleFactor,truncate"`
		AvgObjSize  int64  `bson:"avgObjSize,truncate"`
		DataSize    int64  `bson:"dataSize,truncate"`
		StorageSize int64  `bson:"storageSize,truncate"`
		NumExtents  int64  `bson:"numExtents,truncate"`
	}
}

Database stores database stats

type DatabaseStats added in v1.0.1

type DatabaseStats struct {
	Logger *gox.Logger
	// contains filtered or unexported fields
}

DatabaseStats stores struct

func NewDatabaseStats added in v1.0.1

func NewDatabaseStats(version string) *DatabaseStats

NewDatabaseStats returns DatabaseStats

func (*DatabaseStats) GetAllDatabasesStats added in v1.0.1

func (p *DatabaseStats) GetAllDatabasesStats(client *mongo.Client, dbNames []string) ([]Database, error)

GetAllDatabasesStats gets all db info

func (*DatabaseStats) SetFastMode added in v1.2.1

func (p *DatabaseStats) SetFastMode(fastMode bool)

SetFastMode sets fastMode mode

func (*DatabaseStats) SetNumberShards added in v1.1.5

func (p *DatabaseStats) SetNumberShards(n int)

SetNumberShards set # of threads

func (*DatabaseStats) SetNumberThreads added in v1.0.1

func (p *DatabaseStats) SetNumberThreads(threads int)

SetNumberThreads set # of threads

func (*DatabaseStats) SetRedaction added in v1.0.1

func (p *DatabaseStats) SetRedaction(redaction bool)

SetRedaction sets redaction

func (*DatabaseStats) SetVerbose added in v1.0.1

func (p *DatabaseStats) SetVerbose(verbose bool)

SetVerbose sets verbosity

type Explain added in v1.0.1

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

Explain stores explain object info

func NewExplain added in v1.0.1

func NewExplain() *Explain

NewExplain returns Explain struct

func (*Explain) ExecuteAllPlans added in v1.0.1

func (e *Explain) ExecuteAllPlans(client *mongo.Client, filename string) error

ExecuteAllPlans calls queryPlanner and cardinality

func (*Explain) PrintExplainResults added in v1.0.1

func (e *Explain) PrintExplainResults(filename string) error

PrintExplainResults prints explain results

func (*Explain) SetVerbose added in v1.0.1

func (e *Explain) SetVerbose(verbose bool)

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 Histogram added in v1.0.1

type Histogram struct {
	UTC string         `bson:"utc"`
	Ops map[string]int `bson:"Ops"`
}

Histogram stores ops info

type HostInfo added in v1.0.1

type HostInfo struct {
	Extra struct {
		KernelVersion string
	}
	OS struct {
		Name    string
		Type    string
		Version string
	}
	System struct {
		CPUAddrSize int    `bson:"cpuAddrSize,truncate"`
		CPUArch     string `bson:"cpuArch"`
		Hostname    string `bson:"hostname"`
		MemLimitMB  int    `bson:"memLimitMB,truncate"`
		MemSizeMB   int    `bson:"memSizeMB,truncate"`
		NumaEnabled bool   `bson:"numaEnabled"`
		NumCores    int    `bson:"numCores,truncate"`
	}
}

HostInfo stores build information

func GetHostInfo added in v1.0.1

func GetHostInfo(client *mongo.Client) (HostInfo, error)

GetHostInfo returns MongoDB build information

type Index added in v1.0.1

type Index struct {
	Background              bool   `json:"background" bson:"background"`
	Collation               bson.D `json:"collation" bson:"collation"`
	ExpireAfterSeconds      int32  `json:"expireAfterSeconds" bson:"expireAfterSeconds,truncate,omitempty"`
	Key                     bson.D `json:"key" bson:"key"`
	Name                    string `json:"name" bson:"name,truncate"`
	PartialFilterExpression bson.D `json:"partialFilterExpression" bson:"partialFilterExpression"`
	Sparse                  bool   `json:"sparse" bson:"sparse"`
	Unique                  bool   `json:"unique" bson:"unique"`
	Version                 int32  `json:"v" bson:"v,truncate"`
	Weights                 bson.D `json:"weights" bson:"weights"`

	EffectiveKey string       `json:"effectiveKey" bson:"effectiveKey"`
	Fields       []string     `json:"fields" bson:"fields"`
	IsDupped     bool         `json:"isDupped" bson:"isDupped"`
	IsShardKey   bool         `json:"isShardkey" bson:"isShardkey"`
	KeyString    string       `json:"keyString" bson:"keyString"`
	TotalOps     int          `json:"totalOps" bson:"totalOps"`
	Usage        []IndexUsage `json:"usage" bson:"usage"`
}

Index stores indexes stats

type IndexNS added in v1.0.6

type IndexNS struct {
	From string
	To   string
}

IndexNS defines from and to namespaces

type IndexScore added in v1.0.1

type IndexScore struct {
	Index gox.OrderedMap `json:"index"`
	Score float64        `json:"score"`
}

IndexScore keeps index score

type IndexStats added in v1.0.1

type IndexStats struct {
	Databases []Database  `bson:"databases"`
	Logger    *gox.Logger `bson:"keyhole"`
	// contains filtered or unexported fields
}

IndexStats holder indexes reader struct

func NewIndexStats added in v1.0.1

func NewIndexStats(version string) *IndexStats

NewIndexStats establish seeding parameters

func (*IndexStats) CopyIndexes added in v1.1.5

func (ix *IndexStats) CopyIndexes(client *mongo.Client, isDrop bool, namespaces ...[]string) error

CopyIndexes copies indexes

func (*IndexStats) CopyIndexesWithDest added in v1.1.5

func (ix *IndexStats) CopyIndexesWithDest(client *mongo.Client, namespaces []IndexNS, isDrop bool) error

CopyIndexesWithDest copies indexes

func (*IndexStats) CreateIndexes added in v1.0.1

func (ix *IndexStats) CreateIndexes(client *mongo.Client, namespaces ...[]string) error

CreateIndexes creates indexes

func (*IndexStats) GetIndexes added in v1.0.1

func (ix *IndexStats) GetIndexes(client *mongo.Client) ([]Database, error)

GetIndexes list all indexes of collections of databases

func (*IndexStats) GetIndexesFromCollection added in v1.0.1

func (ix *IndexStats) GetIndexesFromCollection(client *mongo.Client, collection *mongo.Collection) ([]Index, error)

GetIndexesFromCollection gets indexes from a collection

func (*IndexStats) GetIndexesFromDB added in v1.0.1

func (ix *IndexStats) GetIndexesFromDB(client *mongo.Client, db string) ([]Collection, error)

GetIndexesFromDB list all indexes of collections of a database

func (*IndexStats) OutputBSON added in v1.0.1

func (ix *IndexStats) OutputBSON() (string, []byte, error)

OutputBSON writes index stats bson to a file

func (*IndexStats) OutputJSON added in v1.0.1

func (ix *IndexStats) OutputJSON() error

OutputJSON writes json data to a file

func (*IndexStats) Print added in v1.0.1

func (ix *IndexStats) Print()

Print prints indexes

func (*IndexStats) PrintIndexesOf added in v1.0.1

func (ix *IndexStats) PrintIndexesOf(databases []Database)

PrintIndexesOf prints indexes

func (*IndexStats) SetClusterDetailsFromFile added in v1.0.1

func (ix *IndexStats) SetClusterDetailsFromFile(filename string) error

SetClusterDetailsFromFile File sets cluster details from a file

func (*IndexStats) SetFastMode added in v1.2.1

func (ix *IndexStats) SetFastMode(fastMode bool)

SetFastMode sets fastMode mode

func (*IndexStats) SetFilename added in v1.0.1

func (ix *IndexStats) SetFilename(filename string)

SetFilename sets output file name

func (*IndexStats) SetNoColor added in v1.0.1

func (ix *IndexStats) SetNoColor(nocolor bool)

SetNoColor set nocolor flag

func (*IndexStats) SetVerbose added in v1.0.1

func (ix *IndexStats) SetVerbose(verbose bool)

SetVerbose sets verbose level

type IndexUsage added in v1.0.1

type IndexUsage struct {
	Accesses Accesses `json:"accesses" bson:"accesses"`
	Host     string   `json:"host" bson:"host"`
	Name     string   `json:"name" bson:"name"`
	Shard    string   `json:"shard" bson:"shard"`
}

IndexUsage stores index accesses

type ListDatabases added in v1.0.1

type ListDatabases struct {
	Databases   []Database `bson:"databases"`
	TotalSize   int64      `bson:"totalSize"`
	TotalSizeMB int64      `bson:"totalSizeMb"`
}

ListDatabases stores listDatabases

type LogInfo added in v1.0.1

type LogInfo struct {
	Collscan   bool        `bson:"collscan"`
	Histogram  []Histogram `bson:"histogram"`
	Logger     *gox.Logger `bson:"keyhole"`
	LogType    string      `bson:"type"`
	Regex      string      `bson:"regex"`
	OpPatterns []OpPattern `bson:"opPatterns"`
	Redaction  bool        `bson:"redact"`
	SlowOps    []SlowOps   `bson:"slowOps"`
	// contains filtered or unexported fields
}

LogInfo keeps loginfo struct

func NewLogInfo added in v1.0.1

func NewLogInfo(version string) *LogInfo

NewLogInfo -

func (*LogInfo) AnalyzeFile added in v1.0.1

func (li *LogInfo) AnalyzeFile(filename string) error

AnalyzeFile analyze logs from a file

func (*LogInfo) OutputBSON added in v1.0.1

func (li *LogInfo) OutputBSON() (string, []byte, error)

OutputBSON writes loginfo bson data

func (*LogInfo) OutputJSON added in v1.0.1

func (li *LogInfo) OutputJSON() error

OutputJSON writes json data to a file

func (*LogInfo) Parse added in v1.0.1

func (li *LogInfo) Parse(reader *bufio.Reader, counts ...int) error

Parse parse text or json

func (*LogInfo) ParseLog added in v1.0.1

func (li *LogInfo) ParseLog(str string) (LogStats, error)

ParseLog - parses text message before v4.4

func (*LogInfo) ParseLogv2 added in v1.0.1

func (li *LogInfo) ParseLogv2(str string) (LogStats, error)

ParseLogv2 - parses text message before v4.4

func (*LogInfo) Print added in v1.0.1

func (li *LogInfo) Print()

Print prints indexes

func (*LogInfo) SetCollscan added in v1.0.1

func (li *LogInfo) SetCollscan(collscan bool)

SetCollscan -

func (*LogInfo) SetRedaction added in v1.0.1

func (li *LogInfo) SetRedaction(redaction bool)

SetRedaction sets redaction

func (*LogInfo) SetRegexPattern added in v1.0.1

func (li *LogInfo) SetRegexPattern(regex string)

SetRegexPattern sets Regex patthen

func (*LogInfo) SetSilent added in v1.0.1

func (li *LogInfo) SetSilent(silent bool)

SetSilent -

func (*LogInfo) SetVerbose added in v1.0.1

func (li *LogInfo) SetVerbose(verbose bool)

SetVerbose -

type LogStats added in v1.0.1

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

LogStats log stats structure

type LogVersion2 added in v1.0.8

type LogVersion2 struct {
	Attributes struct {
		Command            bson.M `json:"command" bson:"command"`
		Milli              int    `json:"durationMillis" bson:"durationMillis"`
		NS                 string `json:"ns" bson:"ns"`
		OriginatingCommand bson.M `json:"originatingCommand" bson:"originatingCommand"`
		PlanSummary        string `json:"planSummary" bson:"planSummary"`
		Type               string `json:"type" bson:"type"`
	} `json:"attr" bson:"attr"`
	Component string             `json:"c" bson:"c"`
	Context   string             `json:"ctx" bson:"ctx"`
	ID        int                `json:"id" bson:"id"`
	Message   string             `json:"msg" bson:"msg"`
	Severity  string             `json:"s" bson:"s"`
	DateTime  primitive.DateTime `json:"t" bson:"t"`
}

LogVersion2 stores logv2 info

type Logv2 added in v1.0.1

type Logv2 struct {
	Attributes struct {
		Command            map[string]interface{} `json:"command" bson:"command"`
		Milli              int                    `json:"durationMillis" bson:"durationMillis"`
		NS                 string                 `json:"ns" bson:"ns"`
		OriginatingCommand map[string]interface{} `json:"originatingCommand" bson:"originatingCommand"`
		PlanSummary        string                 `json:"planSummary" bson:"planSummary"`
		Type               string                 `json:"type" bson:"type"`
	} `json:"attr" bson:"attr"`
	Component string            `json:"c" bson:"c"`
	ID        int               `json:"id" bson:"id"`
	Message   string            `json:"msg" bson:"msg"`
	Severity  string            `json:"s" bson:"s"`
	Timestamp map[string]string `json:"t" bson:"t"`
}

Logv2 stores logv2 info

type OpPattern added in v1.0.1

type OpPattern 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
}

OpPattern stores performance data

type OplogStats added in v1.0.1

type OplogStats struct {
	Count             int   `bson:"count"`
	DurationInSeconds int64 `bson:"durationInSeconds"`
	MaxSize           int64 `bson:"maxSize"`
	Size              int64 `bson:"size"`
}

OplogStats stores oplog stats

func GetOplogStats added in v1.0.1

func GetOplogStats(client *mongo.Client) (OplogStats, error)

GetOplogStats returns 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 NewRedactor added in v1.0.1

func NewRedactor() *Redactor

NewRedactor returns Redact struct

func (*Redactor) SetVerbose added in v1.0.1

func (r *Redactor) SetVerbose(verbose bool)

SetVerbose sets verbosity

type ReplSetGetStatus added in v1.0.1

type ReplSetGetStatus struct {
	Members []struct {
		ID             int                              `bson:"_id"`
		Health         int                              `bson:"health"`
		Name           string                           `bson:"name"`
		Optime         struct{ TS primitive.Timestamp } `bson:"optime"`
		State          int                              `bson:"state"`
		StateStr       string                           `bson:"stateStr"`
		SyncingTo      string                           `bson:"syncingTo"`
		SyncSourceHost string                           `bson:"syncSourceHost"`
		Uptime         int64                            `bson:"uptime"`
	} `bson:"members"`
	Set            string `bson:"set"`
	SyncingTo      string `bson:"syncingTo"`
	SyncSourceHost string `bson:"syncSourceHost"`
}

ReplSetGetStatus stores replset info

func GetReplSetGetStatus added in v1.0.1

func GetReplSetGetStatus(client *mongo.Client) (ReplSetGetStatus, error)

GetReplSetGetStatus returns MongoDB build information

type ServerStatus added in v1.0.1

type ServerStatus struct {
	Connections struct {
		Active       int `bson:"active"`
		Current      int `bson:"current"`
		Available    int `bson:"available"`
		TotalCreated int `bson:"totalCreated"`
	} `bson:"connections"`
	Host      string    `bson:"host"`
	LocalTime time.Time `bson:"localTime"`
	Mem       struct {
		Virtual   int  `bson:"virtual"`
		Supported bool `bson:"supported"`
		Bits      int  `bson:"bits"`
		Resident  int  `bson:"resident"`
	} `bson:"mem"`
	Metrics struct {
		Cursor struct {
			Open struct {
				Pinned int `bson:"pinned"`
				Total  int `bson:"total"`
			} `bson:"open"`
		} `bson:"cursor"`
	} `bson:"metrics"`
	OpCounters struct {
		Command int `bson:"command"`
		Insert  int `bson:"insert"`
		Query   int `bson:"query"`
		Update  int `bson:"update"`
		Delete  int `bson:"delete"`
		GetMore int `bson:"getmore"`
	} `bson:"opcounters"`
	Process string `bson:"process"`
	Repl    struct {
		Hosts     []string `bson:"hosts"`
		IsMaster  bool     `bson:"isMaster"`
		Me        string   `bson:"me"`
		Primary   string   `bson:"primary"`
		SetName   string   `bson:"setName"`
		Secondary bool     `bson:"secondary"`
	} `bson:"repl"`
	Sharding struct {
		ConfigsvrConnectionString string `bson:"configsvrConnectionString"`
		MaxChunkSizeInBytes       int    `bson:"maxChunkSizeInBytes"`
	} `bson:"sharding"`
	StorageEngine struct {
		Name string `bson:"name"`
	} `bson:"storageEngine"`
	Version    string `bson:"version"`
	WiredTiger struct {
		Cache bson.M `bson:"cache"`
	} `bson:"wiredTiger"`
}

ServerStatus stores build information

func GetServerStatus added in v1.0.1

func GetServerStatus(client *mongo.Client) (ServerStatus, error)

GetServerStatus returns MongoDB build information

type Shard added in v1.0.1

type Shard struct {
	ID      string         `bson:"_id"`
	Host    string         `bson:"host"`
	State   int            `bson:"state"`
	Servers []ClusterStats `bson:"servers"`
	Tags    []string       `bson:"tags"`
}

Shard store shard information

func GetShards

func GetShards(client *mongo.Client) ([]Shard, error)

GetShards return all shards from listShards command

type SlowOps added in v1.0.1

type SlowOps struct {
	Milli int
	Log   string
}

SlowOps holds slow ops log and time

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 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(version string) *WiredTigerCache

NewWiredTigerCache returns *WiredTigerCache

func (*WiredTigerCache) GetAllDatabasesStats added in v1.0.1

func (wtc *WiredTigerCache) GetAllDatabasesStats(client *mongo.Client) error

GetAllDatabasesStats 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(client *mongo.Client)

Start starts a web server and a thread to collect caches

Jump to

Keyboard shortcuts

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