cockroach: Index | Files | Directories

package status

import ""


Package Files

disk_counters.go health_check.go recorder.go runtime.go runtime_jemalloc.go

func GetTotalMemory Uses

func GetTotalMemory(ctx context.Context) (int64, error)

GetTotalMemory returns either the total system memory (in bytes) or if possible the cgroups available memory.

func GetTotalMemoryWithoutLogging Uses

func GetTotalMemoryWithoutLogging() (int64, string, error)

GetTotalMemoryWithoutLogging is the same as GetTotalMemory, but returns any warning as a string instead of logging it.

type CGoMemStats Uses

type CGoMemStats struct {
    // CGoAllocated represents allocated bytes.
    CGoAllocatedBytes int64
    // CGoTotal represents total bytes (allocated + metadata etc).
    CGoTotalBytes int64

CGoMemStats reports what has been allocated outside of Go.

func GetCGoMemStats Uses

func GetCGoMemStats(ctx context.Context) *CGoMemStats

GetCGoMemStats collects non-Go memory statistics.

type GoMemStats Uses

type GoMemStats struct {
    // Collected is the timestamp at which these values were collected.
    Collected time.Time

GoMemStats groups a runtime.MemStats structure with the timestamp when it was collected.

type HealthChecker Uses

type HealthChecker struct {
    // contains filtered or unexported fields

A HealthChecker inspects the node metrics and optionally a NodeStatus for anomalous conditions that the operator should be alerted to.

func NewHealthChecker Uses

func NewHealthChecker(trackedMetrics map[string]threshold) *HealthChecker

NewHealthChecker creates a new health checker that emits alerts whenever the given metrics are nonzero. Setting the boolean map value indicates a gauge (in which case it is reported whenever it's nonzero); otherwise the metric is treated as a counter and reports whenever it is incremented between consecutive calls of `CheckHealth`.

func (*HealthChecker) CheckHealth Uses

func (h *HealthChecker) CheckHealth(
    ctx context.Context, nodeStatus statuspb.NodeStatus,
) statuspb.HealthCheckResult

CheckHealth performs a (cheap) health check.

type MetricsRecorder Uses

type MetricsRecorder struct {
    // contains filtered or unexported fields

MetricsRecorder is used to periodically record the information in a number of metric registries.

Two types of registries are maintained: "node-level" registries, provided by node-level systems, and "store-level" registries which are provided by each store hosted by the node. There are slight differences in the way these are recorded, and they are thus kept separate.

func NewMetricsRecorder Uses

func NewMetricsRecorder(
    clock *hlc.Clock,
    nodeLiveness *kvserver.NodeLiveness,
    rpcContext *rpc.Context,
    gossip *gossip.Gossip,
    settings *cluster.Settings,
) *MetricsRecorder

NewMetricsRecorder initializes a new MetricsRecorder object that uses the given clock.

func (*MetricsRecorder) AddNode Uses

func (mr *MetricsRecorder) AddNode(
    reg *metric.Registry,
    desc roachpb.NodeDescriptor,
    startedAt int64,
    advertiseAddr, httpAddr, sqlAddr, tenantAddr string,

AddNode adds the Registry from an initialized node, along with its descriptor and start time.

func (*MetricsRecorder) AddStore Uses

func (mr *MetricsRecorder) AddStore(store storeMetrics)

AddStore adds the Registry from the provided store as a store-level registry in this recorder. A reference to the store is kept for the purpose of gathering some additional information which is present in store status summaries. Stores should only be added to the registry after they have been started.

func (*MetricsRecorder) ExportToGraphite Uses

func (mr *MetricsRecorder) ExportToGraphite(
    ctx context.Context, endpoint string, pm *metric.PrometheusExporter,
) error

ExportToGraphite sends the current metric values to a Graphite server. It creates a new PrometheusExporter each time to avoid needing to worry about races with mr.promMu.prometheusExporter. We are not as worried about the extra memory allocations.

func (*MetricsRecorder) GenerateNodeStatus Uses

func (mr *MetricsRecorder) GenerateNodeStatus(ctx context.Context) *statuspb.NodeStatus

GenerateNodeStatus returns a status summary message for the node. The summary includes the recent values of metrics for both the node and all of its component stores. When the node isn't initialized yet, nil is returned.

func (*MetricsRecorder) GetMetricsMetadata Uses

func (mr *MetricsRecorder) GetMetricsMetadata() map[string]metric.Metadata

GetMetricsMetadata returns the metadata from all metrics tracked in the node's nodeRegistry and a randomly selected storeRegistry.

func (*MetricsRecorder) GetTimeSeriesData Uses

func (mr *MetricsRecorder) GetTimeSeriesData() []tspb.TimeSeriesData

GetTimeSeriesData serializes registered metrics for consumption by CockroachDB's time series system.

func (*MetricsRecorder) MarshalJSON Uses

func (mr *MetricsRecorder) MarshalJSON() ([]byte, error)

MarshalJSON returns an appropriate JSON representation of the current values of the metrics being tracked by this recorder.

func (*MetricsRecorder) PrintAsText Uses

func (mr *MetricsRecorder) PrintAsText(w io.Writer) error

PrintAsText writes the current metrics values as plain-text to the writer. We write metrics to a temporary buffer which is then copied to the writer. This is to avoid hanging requests from holding the lock.

func (*MetricsRecorder) WriteNodeStatus Uses

func (mr *MetricsRecorder) WriteNodeStatus(
    ctx context.Context, db *kv.DB, nodeStatus statuspb.NodeStatus,
) error

WriteNodeStatus writes the supplied summary to the given client.

type RuntimeStatSampler Uses

type RuntimeStatSampler struct {

    // Metric gauges maintained by the sampler.
    // Go runtime stats.
    CgoCalls       *metric.Gauge
    Goroutines     *metric.Gauge
    GoAllocBytes   *metric.Gauge
    GoTotalBytes   *metric.Gauge
    CgoAllocBytes  *metric.Gauge
    CgoTotalBytes  *metric.Gauge
    GcCount        *metric.Gauge
    GcPauseNS      *metric.Gauge
    GcPausePercent *metric.GaugeFloat64
    // CPU stats.
    CPUUserNS              *metric.Gauge
    CPUUserPercent         *metric.GaugeFloat64
    CPUSysNS               *metric.Gauge
    CPUSysPercent          *metric.GaugeFloat64
    CPUCombinedPercentNorm *metric.GaugeFloat64
    // Memory stats.
    RSSBytes *metric.Gauge
    // File descriptor stats.
    FDOpen      *metric.Gauge
    FDSoftLimit *metric.Gauge
    // Disk and network stats.
    HostDiskReadBytes      *metric.Gauge
    HostDiskReadCount      *metric.Gauge
    HostDiskReadTime       *metric.Gauge
    HostDiskWriteBytes     *metric.Gauge
    HostDiskWriteCount     *metric.Gauge
    HostDiskWriteTime      *metric.Gauge
    HostDiskIOTime         *metric.Gauge
    HostDiskWeightedIOTime *metric.Gauge
    IopsInProgress         *metric.Gauge
    HostNetRecvBytes       *metric.Gauge
    HostNetRecvPackets     *metric.Gauge
    HostNetSendBytes       *metric.Gauge
    HostNetSendPackets     *metric.Gauge
    // Uptime and build.
    Uptime         *metric.Gauge // We use a gauge to be able to call Update.
    BuildTimestamp *metric.Gauge
    // contains filtered or unexported fields

RuntimeStatSampler is used to periodically sample the runtime environment for useful statistics, performing some rudimentary calculations and storing the resulting information in a format that can be easily consumed by status logging systems.

func NewRuntimeStatSampler Uses

func NewRuntimeStatSampler(ctx context.Context, clock *hlc.Clock) *RuntimeStatSampler

NewRuntimeStatSampler constructs a new RuntimeStatSampler object.

func (*RuntimeStatSampler) GetCPUCombinedPercentNorm Uses

func (rsr *RuntimeStatSampler) GetCPUCombinedPercentNorm() float64

GetCPUCombinedPercentNorm is part of the rowexec.RuntimeStats interface.

func (*RuntimeStatSampler) SampleEnvironment Uses

func (rsr *RuntimeStatSampler) SampleEnvironment(
    ctx context.Context, ms *GoMemStats, cs *CGoMemStats,

SampleEnvironment queries the runtime system for various interesting metrics, storing the resulting values in the set of metric gauges maintained by RuntimeStatSampler. This makes runtime statistics more convenient for consumption by the time series and status systems.

This method should be called periodically by a higher level system in order to keep runtime statistics current.

SampleEnvironment takes GoMemStats as input because that is collected separately, on a different schedule. The CGoMemStats should be provided via GetCGoMemStats().



Package status imports 40 packages (graph) and is imported by 120 packages. Updated 2020-08-13. Refresh now. Tools for package owners.