Files
seaweedfs/weed/stats/metrics.go
T
Chris LuandClaude Opus 5.5 284d491587 s3: forward notification topics to webhook targets (#13245)
* util: move the guarded dialer out of the volume server

The deny list and the dialer that re-checks every resolved address at
connect time move into weed/util/netguard, with the allow-private knob as a
policy, so other outbound clients can dial through the same guard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mq: fence consumer group position saves by generation

A position saved with a generation is written only while the stored one
carries no newer generation, or the same generation from another writer:
the save reads the stored position and writes on the condition that it is
unchanged, routed to the entry's owner filer, and re-reads when another
writer got there first. A single consumer that elects itself can then store
its offsets without a deposed predecessor overwriting them. Saves without a
generation keep overwriting as before.

Loading a missing position now reports ErrNotFound instead of trying every
filer and marking each one failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: post bucket event batches to a webhook target

A webhook destination renders a batch of records as one
{"Records":[...]} body, posts it with the target's bearer token, and takes
any 2xx as delivered. The renderer is a function the destination holds, a
stand-in that refuses until the record renderer lands. It dials through the
guarded dialer under a new Local policy, which refuses metadata-service,
link-local and unspecified addresses at connect time but lets an operator
point a target at a private host or a sidecar on loopback. Redirects are
followed only to the endpoint's own host and never down from https.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: forward each target's topic to its destination

A Forwarder runs beside the Publisher on every gateway. Each enabled target
with a destination gets a lock, s3.notify.<target>, held through
LockClient.StartLongLivedLock, so one gateway forwards a target and targets
spread across gateways; a topic target has none.

The holder runs one loop per partition of the target's topic: fetch from the
stored offset at the partition's leader, decode the records, deliver them as
one batch, store the next offset. A fetch that stops short at a segment
boundary just continues from its next offset. A failed send, a rejected one
included, blocks the partition and is retried with capped backoff, and the
offset is stored only after the destination took the batch. An offset that
retention removed skips to the earliest one and counts the gap.

Offsets go to the consumer group offset storage under group forwarder,
fenced by the lock generation. On taking the lock a forwarder stores each
partition's offset back under its generation, so an older holder's saves are
refused and it stops. A stored generation at or above its own means the
lock was lost, unless the forwarder has since held the lock through a full
renewal, which happens only when the lock server's counter restarted; it
then fences above the stored generation.

Metrics per target: records delivered, send retries, retention gaps, and
lag from the forwarding gateway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: run notification forwarders beside the publisher

Every gateway with filers starts a Forwarder with the publisher. It elects
itself per target through the gateway's object-write lock client, stores
offsets in the filer, reads through the same brokers the publisher uses,
follows the target registry as the publisher does, and releases its locks
on shutdown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: post a test event to a webhook on its own

The renderer refuses an s3:TestEvent that shares a body with other records,
so a webhook splits a batch around each one and posts them in order, the
test event as its own body. The test is a stand-in until the renderer's
lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: skip a bucket event record that can never be delivered

A record that does not decode, or that the renderer refuses, used to be
retried like a failed send and would block its partition for good. The
webhook now renders a whole batch before posting any of it and names the
records that cannot render; the forwarder drops those, counts them per
target and reason in notification_skipped_records_total, logs each offset
once, and sends the rest. Only transport and HTTP failures are retried.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mq: read a fenced position save at the filer that applies it

The fenced save read the stored position from whichever filer answered and
then sent its conditional write to the key's owner, so with filers that keep
their own stores the condition could be checked against an entry other than
the one read, failing until replication caught up or judging a stale copy.
The storage now takes the ring's owner lookup, the one route-by-key writes
already use, and sends both the read and the write to that filer. The
gateway hands its object-write lock client's PrimaryForKey to the forwarder
offsets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: follow a repartitioned notification topic

A forwarder listed its topic's partitions once, when it took the lock, so a
repartition left the new partitions unforwarded until the lock moved. It now
lists them again every 30 seconds, starts a loop for each new partition, and
marks the loops of partitions no longer listed as replaced; such a loop keeps
delivering what its partition holds and ends once it has caught up. A
failed fetch now looks up the leader of that exact partition, not of any
partition with the same range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: let the first forwarder take the lock before the second asks

The election test synced both gateways at once, and each forwarder asks for
its lock from its own goroutine, so the second could ask first and store the
offsets the test expected from the first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: warn when a partition returns nothing below its high-water mark

A fetch that returned no records and kept its next offset below the
high-water mark looked like an idle partition, so the forwarder waited
without a word while its lag stayed up. It still waits, since skipping would
lose the records, but now warns at most once a minute with the topic,
partition, offset and high-water mark, so the lag has an explanation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: render webhook bodies with the bucket event renderer

The webhook now renders through Render and posts each s3:TestEvent alone by
IsTestEvent, replacing the stand-ins it held until the renderer landed.
The tests send real records and read the object keys and test request ids
back out of the bodies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* netguard: refuse the IPv6 and Alibaba metadata service addresses

AWS's IPv6 metadata address fd00:ec2::254 is unique-local and Alibaba's
100.100.100.200 sits in the CGNAT range, so the Private and Local
policies let a webhook or remote endpoint reach them. Refuse both under
every policy, like 169.254.169.254.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* grafana: chart the notification forwarder metrics

Add an S3 Notifications row with delivered records, lag, send retries,
and records skipped or lost to retention per target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: follow only webhook redirects that keep the POST

On a 301, 302 or 303 Go resends the request as a GET without a body, so an
endpoint that redirected and then answered 2xx counted as delivered while
it received no records. Only 307 and 308, which keep the method and resend
the body, are followed now; any other redirect fails the send and is
retried.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: keep webhook endpoint secrets out of errors and logs

The guarded dialer names its endpoint in every refusal, and the forwarder
logs that error, so a webhook endpoint carrying credentials in its userinfo
or a token in its query had them written to the log. The dialer now gets
the endpoint as scheme, host and path only, and the parse and request
errors no longer echo the URL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mq: load a consumer group position from its owner filer

A forwarder taking over read its start offset from whichever filer answered,
while its fenced saves read and write at the key's owner. With filers that
keep their own stores, a replica still holding an older offset handed the
new holder that offset, which it then stored under its higher generation at
the owner, replaying everything delivered since. Loads now go to the owner
too when the storage knows it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mq: bound consumer group position loads and saves by the caller

LoadConsumerGroupPosition and SaveConsumerGroupPosition ran their filer
calls under context.Background(), so a filer whose store stalled held a
forwarder's save forever: ending the lead waited on it, the lock was never
released, and Close hung while the lock kept renewing. Both now take the
caller's context; the forwarder gives each call its RPC deadline under the
lead's context, so stopping returns and the lock is released. The offset
wrappers the broker uses keep their signatures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mq: list a consumer group's positions across partition generations

ListConsumerGroupPositions walks every generation and range directory of a
topic and returns the group's stored position in each, keyed by partition
directory, so a consumer can tell which ranges it holds offsets for that
the topic no longer lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: stop forwarding ranges a repartition removed

A repartition drops the old assignments, and the broker serves only
assigned ranges, so the loop draining a removed range retried a refused
fetch forever, and after a restart nothing looked at it at all. Reading a
removed range's flushed data would need a read-only path in the broker.
Until then a removed range's loop delivers the batch it holds and ends,
and the forwarder logs an error naming each range it stops and, when it
takes the lock, each partition directory holding a stored offset the topic
no longer lists. The fake broker now refuses unassigned ranges as the real
one does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: deliver what a repartition left in the retired ranges

The lookup now offers the sealed ranges a repartition retired, and any
broker serves them from their files, so the forwarder no longer drops
them. On taking the lock and on each re-list it asks for the retired
ranges too and runs a loop for each, from its stored offset up to its
high-water mark, after which the loop ends; a range it was forwarding as
current and that is now retired gets the same end. A read below a retired
range's log start counts as a retention gap, as for a live one.

A key's records in a retired range precede its records in the ranges that
replaced it, and loops running side by side would not keep that order. So
the retired ranges go first, one generation at a time, oldest first, and
the current ranges start only once none is left. A range listed neither as
assigned nor as retired, as while a drained range is not sealed yet, pauses
until it is offered again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: match a retired range to its forwarding loop by directory

The broker lists a retired range at the second its generation directory
is named for, while the assignment the forwarder started its loop from
carried nanoseconds. After a repartition the retired entry missed the
running loop, so a second loop started on the same stored offset and
delivered the batch the first was still retrying. Key the loops by
partition directory; the fake broker now lists retired ranges and the
fake positions store offsets at that resolution, like the real ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: replace a paused forwarding loop only once it ended

A range drained but not sealed yet is listed neither as assigned nor as
retired, so its loop is paused and dropped from the lead's loops while
it may still be retrying a batch. Once the range was offered as retired
a new loop started at the stored offset and sent that batch again. Keep
a paused loop until it ends, and start the range again only then.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: hold the new ranges while a drained one is not sealed yet

A repartition saves the new ranges before it drains and seals the old ones,
so for a while an old range is offered neither as assigned nor as retired,
and the forwarder started the new ranges at once: a key's new records could
go out before its records still waiting in the old range. On each look at
the topic the forwarder now lists the directories holding a stored offset
that the topic does not offer, and probes each at its offset; one that may
still hold records past it, refused because it is not sealed, holds the new
ranges until it is offered as retired and drained. One that answers with
nothing past the stored offset is settled, sealed and empty or already
delivered, and stays so for the lead. While holding, the forwarder logs at
most once a minute and keeps looking even with no loop running.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: have the fake broker serve only the generation a fetch names

The broker now refuses a fetch naming a generation other than the one it
assigns for the range, unless that generation is sealed and read as
retired. The forwarder tests' fake broker matched an assigned range by its
range alone, so it served the live generation to a fetch for an older,
unsealed one; it now matches the generation too, as the broker does.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: hold the current ranges until the stored offsets can be listed

A lead whose first look at the stored offsets failed took that as no old
range left unsettled and started the current ranges, delivering a key's
newer records ahead of the ones still in a drained range that is not sealed
yet. A failed look now holds the current ranges as an unsettled range does,
and is retried with backoff and on each partition refresh; the current
ranges start only after a look succeeds. Retired ranges and loops already
running carry on meanwhile.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3api: leave forwarding off on an unusable broker TLS config

The forwarder loaded the grpc.msg_broker client TLS config with
LoadClientTLS, which exits the process on a bad one, and every gateway with
filers builds a forwarder whether or not it has webhook targets. It now
loads it as the publisher does: an unusable config is logged and leaves
forwarding off while the gateway keeps serving.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: hold the new ranges for an unsealed old range with no stored offset

The check for old ranges still unsealed looked only at ranges holding a
forwarder offset. A forwarder starting for the first time while a drained
range was not sealed yet had stored none in it, so it started the new
ranges and delivered a key's newer records ahead of its older ones. The
consumer group listing now names every partition directory of the topic,
with no position where the group stored none, and such a range is probed
from offset 0. A range with nothing left past that offset, including one
whose records retention already removed, is settled.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* mq: check the load in the fenced save race test

The test read the stored position back ignoring the load's error, so a
failed load panicked on a nil position instead of reporting the error.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* mq: take a partition over at the offset its last holder committed

A new forwarder generation claimed a partition by writing the offset it
had loaded. When the old generation committed again in between, the claim
rewound the stored offset and the new lead replayed what had been
delivered since. A fenced save that takes over from an older generation
now keeps the offset that generation committed last, rereading it on a
conditional write miss, and hands it back in the position, and the
forwarder starts from it.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* mq: wait for a position's owner filer instead of asking another

A position store routed by owner fell back to any filer while the owner
of a key was not known yet, as before the lock ring is learned. That
filer's not-found ended the load there, though it may only not have
caught up, and a claim on it would start the partition over. Loads and
fenced saves now fail until the owner is known, and the forwarder
retries them; a store without an owner routing still uses any filer.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: wait for the last checkpoint before a forwarder handoff in tests

The resume, repartition and election tests stopped the first forwarder
once its records were delivered but possibly before their offsets were
stored, so they could pass on a replay rather than on a committed
handoff. They now wait for the final offsets first.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: have Close wait for removed targets to release their locks

A target removed from the registry had its forwarder cancelled and
dropped from the targets, so a Close soon after did not wait for it and
returned with that target's lock possibly still held. Removed forwarders
are now kept until they are done, and Close waits for them as well.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: hold newer retired generations behind an unsealed older one

A range of an old generation still unsealed held back only the current
ranges. A generation retired after it was offered and delivered right
away, ahead of the older generation's records of the same keys. The
unsealed range's generation now counts as the oldest one left, so only
that generation's own sealed ranges are forwarded until it is sealed.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: check the forwarder lock right before each send

A lead checked its lock at the top of each fetch and after a failed send's
backoff, so a lead that lost the lock while it fetched a batch still sent
it, and the next holder sent it again. The lock is now checked right
before each send. Delivery stays at-least-once: a lock lost during a send
cancels that send once the lead notices, which may be after the endpoint
took the batch.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: read a retired range past a broker that answers with an error

Any broker serves a retired range from its files, but a fetch took the
first broker's answer even when it was a storage error, and each retry
asked that broker first again, so one broker that could not read the
files held the range up for good. A retired fetch answered with an error
other than an offset out of range now goes on to the next broker, and
returns the error only when none could read it.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: count ranges held back behind an older generation in the lag

The lag gauge summed what each running loop reported, so the current
ranges held back while an older generation was still unsealed, and the
retired generations waiting their turn, showed no lag however much piled
up in them. On each partition refresh the lead now reports their lag
from the stored offset to the high-water mark, read from the range's
leader or the retired listing, and drops the lag of ranges it no longer
has.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: hold retired generations too while stored offsets cannot be listed

A lead whose look at the stored offsets failed held only the current
ranges and went on forwarding retired generations, though an older
generation it could not see might still be unsealed and hold earlier
records of the same keys. A failed look now holds every range not yet
running until a look succeeds; loops already running carry on.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: read stored offsets only of the ranges a lead does not know yet

The check for unsettled ranges listed every partition directory and read
every stored offset in it one by one under one deadline, before dropping
the ranges the topic offers and those already found settled. A topic
with many past generations could take longer than the deadline on every
refresh and hold a new lead for good. The listing now takes the
directories to skip and reads only the remaining offsets, a few at a
time, and the lead skips the offered ranges and those it found settled.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: test the failed-listing hold with no unsealed range

The failed-listing test also had an older generation unsealed, which
holds the newer ranges on its own once a listing succeeds, so it did not
show the listing guard by itself. A second case has no unsealed range:
nothing goes out while the listing fails, and both the retired and the
current range do once it succeeds.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: stop the lead before marking a failed loop ended

A forwarding loop that failed, as on being deposed, was marked ended
before it cancelled its lead. A partition refresh in between saw a
retired range's loop ended, took the range as delivered, and started the
next generation's ranges on the lead that was about to stop. The lead is
now cancelled first, so no refresh acts on the failed loop.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: count no retention gap below an offset only claimed

A lead claiming a partition with no stored offset wrote offset 0 to fence
it before reading anything. A lead that stopped there left 0 behind, and
the next one, finding the log start past it, counted those offsets as
lost though no forwarder had ever been at them. A claim made before any
read is now marked as such, a takeover keeps the marker of the entry it
replaces, and only an offset a lead read from counts a gap.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: retry a takeover save at the offset it kept

A claim's save that took a partition over from an older generation kept
that generation's last offset, but when its reply was lost the retry
went out with the offset the claim had loaded. The stored entry was by
then the claim's own, so the retry kept nothing and rewound the
partition, replaying what had been delivered since. A failed save now
retries with the offset and marker the attempt settled on.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: store an offset as read from once the first fetch succeeds

A claimed offset lost its claimed marker only when a later save moved it,
so a lead that read an empty partition and stopped left it marked as
never read. Records published and then removed by retention while no
gateway forwarded the target were skipped without a gap counted or
logged. The first successful fetch now stores the offset as read from,
once per claim, even when it has not moved.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: wait for the stalled topic's publisher before reading it in a test

The worker sets the topic publisher up on its own goroutine, which on a
loaded host can start after Publish has stopped waiting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: keep what a timed-out offset check settled for the next one

A check for unsettled ranges that could not read every stored offset
within its deadline returned nothing, so each retry read the same ranges
again and a long enough history kept the new ranges held for good. The
listing now returns the positions it read along with the error and goes
on past one that fails, and the check probes those and keeps the ranges
it finds settled before reporting the failure, so the next check reads
only the rest. The ranges stay held until a check covers them all.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

* s3: say which records the notification lag counts

The lag gauge's help, and the dashboard panel with none, read as every
undelivered record, but the records of an old range still being sealed
after a repartition cannot be read and are not counted. Both now say the
gauge covers the current ranges, the ranges held back behind an older
generation, and the sealed retired ranges.

Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 21:45:41 -08:00

1566 lines
61 KiB
Go

package stats
import (
"net"
"net/http"
"os"
"runtime"
"strconv"
"strings"
"sync"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/client_golang/prometheus/push"
"github.com/seaweedfs/seaweedfs/weed/glog"
)
// SetVersionInfo sets the version information for the BuildInfo metric
// This is called by the version package during initialization.
// It uses sync.Once to ensure the build information is set only once,
// making it safe to call multiple times while ensuring immutability.
var SetVersionInfo = func() func(string, string, string) {
var once sync.Once
return func(version, commitHash, sizeLimit string) {
once.Do(func() {
BuildInfo.WithLabelValues(version, commitHash, sizeLimit, runtime.GOOS, runtime.GOARCH).Set(1)
})
}
}()
// Readonly volume types
const (
Namespace = "SeaweedFS"
IsReadOnly = "IsReadOnly"
NoWriteOrDelete = "noWriteOrDelete"
NoWriteCanDelete = "noWriteCanDelete"
IsDiskSpaceLow = "isDiskSpaceLow"
bucketAtiveTTL = 10 * time.Minute
)
// Prometheus metric subsystems.
const (
subsystemBuild = "build"
subsystemMaster = "master"
subsystemWDClient = "wdclient"
subsystemFiler = "filer"
subsystemFilerStore = "filerStore"
subsystemFilerSync = "filerSync"
subsystemVolumeServer = "volumeServer"
subsystemS3 = "s3"
subsystemS3Lifecycle = "s3_lifecycle"
subsystemAdmin = "admin"
subsystemRemote = "remote"
)
var bucketLastActiveTsNs map[string]int64 = map[string]int64{}
var bucketLastActiveLock sync.Mutex
var (
Gather = prometheus.NewRegistry()
BuildInfo = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemBuild,
Name: "info",
Help: "A metric with a constant '1' value labeled by version, commit, sizelimit, goos, and goarch from which SeaweedFS was built.",
}, []string{"version", "commit", "sizelimit", "goos", "goarch"})
MasterStartTimeSeconds = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "start_time_seconds",
Help: "Start time of the master, as seconds since UNIX epoch.",
})
MasterClientConnectCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemWDClient,
Name: "connect_updates",
Help: "Counter of master client leader updates.",
}, []string{"type"})
MasterRaftIsleader = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "is_leader",
Help: "is leader",
})
MasterAdminLock = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "admin_lock",
Help: "admin lock",
}, []string{"client"})
MasterVolumeGrowthFrozen = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "volume_growth_frozen",
Help: "1 while volume growth is frozen after detected master state loss",
})
MasterDuplicateVolumeIds = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "duplicate_volume_ids",
Help: "volume id registered under two different layouts",
}, []string{"collection", "volumeId"})
MasterReceivedHeartbeatCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "received_heartbeats",
Help: "Counter of master received heartbeat.",
}, []string{"type"})
MasterReplicaPlacementMismatch = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "replica_placement_mismatch",
Help: "replica placement mismatch",
}, []string{"collection", "id"})
MasterVolumeLayoutWritable = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "volume_layout_writable",
Help: "Number of writable volumes in volume layouts",
}, []string{"collection", "disk", "rp", "ttl"})
MasterVolumeLayoutCrowded = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "volume_layout_crowded",
Help: "Number of crowded volumes in volume layouts",
}, []string{"collection", "disk", "rp", "ttl"})
// MasterUnderReplicatedVolumes tracks volumes that do not have enough replicas,
// partitioned by collection, disk type, replication type, and TTL.
MasterUnderReplicatedVolumes = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "under_replicated_volumes",
Help: "Current number of volumes that do not have enough replicas per collection/layout. 0 = healthy.",
}, []string{"collection", "disk", "rp", "ttl"})
MasterWritableVolumesPerDisk = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "writable_volumes_per_disk",
Help: "Number of writable volumes of a volume layout with a replica on the disk; state=crowded counts those past the grow threshold.",
}, []string{"collection", "disk", "rp", "ttl", "data_center", "rack", "node", "disk_id", "state"})
// MasterVolumeCreationCounter counts volume creation (growth) operations by result (success, failure).
// Volume growth is orchestrated by the master, so this metric is exported by the master process.
MasterVolumeCreationCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "volume_creation_total",
Help: "Counter of volume creation operations by result (success, failure).",
}, []string{"result"})
MasterPickForWriteErrorCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "pick_for_write_error",
Help: "Counter of master pick for write error",
})
MasterBroadcastToFullErrorCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "broadcast_to_full",
Help: "Counter of master broadcast send to full message channel err",
})
MasterLeaderChangeCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemMaster,
Name: "leader_changes",
Help: "Counter of master leader changes.",
}, []string{"type"})
FilerRequestCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "request_total",
Help: "Counter of filer requests.",
}, []string{"type", "code"})
FilerHandlerCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "handler_total",
Help: "Counter of filer handlers.",
}, []string{"type"})
FilerRequestHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "request_seconds",
Help: "Bucketed histogram of filer request processing time.",
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 24),
}, []string{"type"})
// The mounts and the S3 gateway reach the filer over gRPC; the request
// counter and histogram above see its HTTP API only.
FilerGrpcRequestCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "grpc_request_total",
Help: "Counter of filer gRPC requests, by method and gRPC status code.",
}, []string{"method", "code"})
FilerGrpcRequestHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "grpc_request_seconds",
Help: "Bucketed histogram of filer gRPC request processing time, by method.",
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 24),
}, []string{"method"})
FilerInFlightRequestsGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "in_flight_requests",
Help: "Current number of in-flight requests being handled by filer.",
}, []string{"type"})
FilerInFlightUploadBytesGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "in_flight_upload_bytes",
Help: "Current number of bytes being uploaded to filer.",
})
FilerInFlightUploadCountGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "in_flight_upload_count",
Help: "Current number of uploads in progress to filer.",
})
FilerServerLastSendTsOfSubscribeGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "last_send_timestamp_of_subscribe",
Help: "The last send timestamp of the filer subscription.",
}, []string{"sourceFiler", "clientName", "path"})
FilerSubscribeUnprovenGapCrossings = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "subscribe_unproven_gap_crossings",
Help: "Times a metadata subscriber moved past a log range without proof it was persisted: scope=aggregated means a peer may not have flushed it, scope=local means this filer's own log flush was wedged past the give-up bound.",
}, []string{"scope"})
FilerSubscribeWatermarkHolds = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "subscribe_watermark_holds",
Help: "Times an aggregated metadata read stopped at an entry newer than the peers' low-watermark and waited for a peer to report further progress: scope=memory held at the delivery watermark, scope=disk at the flush watermark.",
}, []string{"scope"})
FilerSubscribeGapStalledGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "subscribe_gap_stalled",
Help: "Number of metadata subscribers currently parked waiting to read past a gap in the metadata log.",
}, []string{"scope"})
// Delivery observability for the metadata subscription paths: lag at send
// time, hold durations, ring fall-offs, the delivery claim and the peer
// low-watermarks, so a late delivery can be attributed to a mechanism.
FilerSubscribeDeliveryLagSeconds = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "subscribe_delivery_lag_seconds",
Help: "Seconds from a metadata event's mutation until the filer sends it to the subscriber's stream, measured after the send-queue wait and the actual gRPC send (excludes client receipt): scope=local on the filer's own stream, scope=aggregated on the multi-filer stream.",
Buckets: []float64{0.1, 0.25, 0.5, 1, 2, 5, 10, 20, 30, 45, 60, 90, 120, 180, 300},
}, []string{"scope"})
FilerSubscribeHoldSeconds = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "subscribe_hold_seconds",
Help: "How long an aggregated metadata read stayed held at one entry before the peers' watermark released it: scope=memory at the delivery watermark, scope=disk at the flush watermark.",
Buckets: []float64{0.05, 0.2, 0.5, 1, 2, 5, 10, 20, 30, 60, 120, 300},
}, []string{"scope"})
FilerSubscribeResumeFromDisk = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "subscribe_resume_from_disk",
Help: "Times a metadata subscriber fell off the in-memory ring and resumed from the persisted log (delivery then follows the per-minute flush).",
}, []string{"scope"})
FilerMetaDeliveryClaimAgeSeconds = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "meta_delivery_claim_age_seconds",
Help: "Seconds the filer's delivery claim (what it tells peer aggregators it has delivered through) trails the clock: capped by the oldest commit stamp still in flight.",
})
FilerMetaPeerLowWatermarkAgeSeconds = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "meta_peer_low_watermark_age_seconds",
Help: "Seconds the peers' low-watermark trails the clock (kind=delivery bounds in-memory aggregated reads, kind=flush bounds persisted-log reads); -1 while a tracked peer has not signalled yet.",
}, []string{"kind"})
FilerMetaAggregatorReplayFailures = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "meta_aggregator_replay_failures",
Help: "Number of peer metadata events skipped after replay retries were exhausted, leaving that entry diverged from the peer.",
}, []string{"peer"})
// Sampled only on first creation, so counts track distinct objects.
FilerObjectSizeBytesHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "object_size_bytes",
Help: "Distribution of object sizes in bytes, sampled when an object is first created.",
Buckets: []float64{1024, 102400, 1048576, 104857600, 1073741824},
})
FilerStoreCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFilerStore,
Name: "request_total",
Help: "Counter of filer store requests.",
}, []string{"store", "type"})
FilerRemoteDeletionTombstones = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "remote_deletion_tombstones",
Help: "Paths deleted under a remote mount whose remote delete the write-back daemon has not consumed yet.",
})
FilerRemoteDeletionTombstonesFull = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemFiler,
Name: "remote_deletion_tombstones_full",
Help: "1 from a delete the full table could not record until the table has room and that delete is past the TTL; lazy remote fetches are off meanwhile. 0 otherwise.",
})
FilerStoreHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemFilerStore,
Name: "request_seconds",
Help: "Bucketed histogram of filer store request processing time.",
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 24),
}, []string{"store", "type"})
FilerSyncOffsetGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemFilerSync,
Name: "sync_offset",
Help: "The offset of the filer synchronization service.",
}, []string{"sourceFiler", "targetFiler", "clientName", "path"})
FilerSyncEventsReceivedCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFilerSync,
Name: "events_received_total",
Help: "Counter of metadata events read off the source subscription stream.",
}, []string{"sourceFiler", "targetFiler", "clientName", "path"})
FilerSyncEventsProcessedCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFilerSync,
Name: "events_processed_total",
Help: "Counter of metadata events successfully replicated to the target.",
}, []string{"sourceFiler", "targetFiler", "clientName", "path"})
FilerSyncEventsFailedCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFilerSync,
Name: "events_failed_total",
Help: "Counter of metadata events that failed after retries; the sync offset is held at the oldest failure so it is replayed on restart.",
}, []string{"sourceFiler", "targetFiler", "clientName", "path"})
FilerSyncInFlightJobsGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemFilerSync,
Name: "in_flight_jobs",
Help: "Number of sync jobs currently being replicated; pinned at the concurrency limit means the sync itself is the bottleneck.",
}, []string{"sourceFiler", "targetFiler", "clientName", "path"})
FilerSyncReceivedBytesCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFilerSync,
Name: "received_bytes_total",
Help: "Counter of chunk data bytes carried by received events: new chunks the old entry does not already have, so deletes, renames, and attribute-only updates count zero.",
}, []string{"sourceFiler", "targetFiler", "clientName", "path"})
FilerSyncProcessedBytesCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFilerSync,
Name: "processed_bytes_total",
Help: "Counter of chunk data bytes carried by successfully replicated events.",
}, []string{"sourceFiler", "targetFiler", "clientName", "path"})
FilerSyncFailedBytesCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemFilerSync,
Name: "failed_bytes_total",
Help: "Counter of chunk data bytes carried by events that failed after retries.",
}, []string{"sourceFiler", "targetFiler", "clientName", "path"})
FilerSyncInFlightBytesGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemFilerSync,
Name: "in_flight_bytes",
Help: "Chunk data bytes carried by the jobs currently being replicated; distinguishes workers stuck on a few large files from many small ones.",
}, []string{"sourceFiler", "targetFiler", "clientName", "path"})
FilerSyncLagSecondsGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemFilerSync,
Name: "lag_seconds",
Help: "How far the replicated watermark trails the source filer, in seconds.",
}, []string{"sourceFiler", "targetFiler", "clientName", "path"})
VolumeServerStartTimeSeconds = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "start_time_seconds",
Help: "Start time of the volume server, as seconds since UNIX epoch.",
})
VolumeServerRequestCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "request_total",
Help: "Counter of volume server requests.",
}, []string{"type", "code"})
VolumeServerHandlerCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "handler_total",
Help: "Counter of volume server handlers.",
}, []string{"type"})
VolumeServerVacuumingCompactCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "vacuuming_compact_count",
Help: "Counter of volume vacuuming Compact counter",
}, []string{"success"})
VolumeServerVacuumingCommitCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "vacuuming_commit_count",
Help: "Counter of volume vacuuming commit counter",
}, []string{"success"})
VolumeServerVacuumingDroppedNeedlesCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "vacuuming_dropped_needles",
Help: "Counter of live needles dropped by vacuum because their data could not be read back intact.",
}, []string{"collection"})
VolumeServerVacuumingHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "vacuuming_seconds",
Help: "Bucketed histogram of volume server vacuuming processing time.",
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 24),
}, []string{"type"})
VolumeServerRequestHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "request_seconds",
Help: "Bucketed histogram of volume server request processing time.",
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 24),
}, []string{"type"})
VolumeServerInFlightRequestsGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "in_flight_requests",
Help: "Current number of in-flight requests being handled by volume server.",
}, []string{"type"})
VolumeServerVolumeGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "volumes",
Help: "Number of volumes or shards.",
}, []string{"collection", "type"})
VolumeServerReadOnlyVolumeGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "read_only_volumes",
Help: "Number of read only volumes.",
}, []string{"collection", "type"})
VolumeServerEcShardDiskMismatchGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "ec_shard_disk_mismatch",
Help: "Mounted EC shards whose file on disk is gone or replaced (ghost) or changed size (stale_size).",
}, []string{"reason"})
VolumeServerMaxVolumeCounter = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "max_volumes",
Help: "Maximum number of volumes.",
})
VolumeServerDiskSizeGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "total_disk_size",
Help: "Actual disk size used by volumes.",
}, []string{"collection", "type"})
VolumeServerResourceGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "resource",
Help: "Resource usage",
}, []string{"name", "type"})
VolumeServerDiskErrorGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "disk_error_status",
Help: "Disk error status",
}, []string{"name", "type"})
VolumeServerStorageIoErrorCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "storage_io_error_total",
Help: "Counter of storage read/write EIO errors on volumes and EC shards.",
})
VolumeServerIoQuarantineGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "io_quarantine",
Help: "Number of volumes or EC shards quarantined due to storage IO errors.",
}, []string{"kind"})
VolumeServerConcurrentDownloadLimit = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "concurrent_download_limit",
Help: "Limit total concurrent download size.",
})
VolumeServerConcurrentUploadLimit = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "concurrent_upload_limit",
Help: "Limit total concurrent upload size.",
})
VolumeServerInFlightDownloadSize = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "in_flight_download_size",
Help: "In flight total download size.",
})
VolumeServerInFlightUploadSize = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "in_flight_upload_size",
Help: "In flight total upload size.",
})
VolumeServerMasterDisconnections = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "master_disconnections",
Help: "Number of master server disconnections.",
}, []string{"address"})
VolumeServerFileReadFailures = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "file_read_failures",
Help: "Counter of overall failed file read requests from clients.",
})
VolumeServerFileReadInvalidNeedles = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "file_read_invalid_needles",
Help: "Counter of failed file read requests due to invalid needle IDs from clients.",
})
VolumeServerFileWriteFailures = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "file_write_failures",
Help: "Counter of overall failed file write requests from clients.",
})
VolumeServerScrubLastTimeSeconds = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "scrub_last_time_seconds",
Help: "Last scrub execution time, as seconds since UNIX epoch.",
}, []string{"mode"})
VolumeServerScrubVolumeFailures = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "scrub_volume_failures",
Help: "Counter of overall volumes with issues detected during scrubbing.",
}, []string{"mode"})
VolumeServerScrubShardFailures = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "scrub_shard_failures",
Help: "Counter of overall EC shards with issues detected during scrubbing.",
}, []string{"mode"})
// VolumeServerReplicationCounter counts replication operations by operation type
// (write, delete) and result (success, failure).
VolumeServerReplicationCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "replication_operations_total",
Help: "Counter of replication operations by type (write, delete) and result (success, failure).",
}, []string{"operation", "result"})
// VolumeServerReplicationHistogram records replication operation duration in seconds,
// partitioned by operation type (write, delete).
VolumeServerReplicationHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "replication_seconds",
Help: "Bucketed histogram of replication operation duration in seconds.",
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 24),
}, []string{"operation"})
// VolumeServerReplicationTargets records the number of replica targets per replication
// operation, useful for observing fan-out width.
VolumeServerReplicationTargets = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "replication_targets",
Help: "Histogram of replica targets count per replication operation.",
Buckets: []float64{1, 2, 3, 4, 5},
})
// VolumeServerReplicationFailures counts replication failures by operation type
// and failure reason (timeout, connection_refused, context_cancelled, server_error).
VolumeServerReplicationFailures = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "replication_failures_total",
Help: "Counter of replication failures by operation and reason (timeout, connection_refused, context_cancelled, server_error).",
}, []string{"operation", "reason"})
// VolumeServerECRebuildHistogram records the duration of EC shard rebuild operations by result (success, failure).
VolumeServerECRebuildHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "ec_rebuild_seconds",
Help: "Bucketed histogram of EC shard rebuild/reconstruct duration by result.",
Buckets: prometheus.ExponentialBuckets(0.01, 2, 20),
}, []string{"result"})
// VolumeServerECRebuildCounter counts EC shard rebuild operations by result (success, failure).
VolumeServerECRebuildCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "ec_rebuild_total",
Help: "Counter of EC shard rebuild operations by result.",
}, []string{"result"})
// VolumeServerECReconstructedIntervalCounter counts reads of an EC shard
// interval that could not be read directly and were served by reconstructing
// it from the other shards. success means the reconstruction produced data,
// not that the needle then passed validation.
VolumeServerECReconstructedIntervalCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "ec_reconstructed_interval_total",
Help: "Reads of an EC interval served by reconstructing from other shards; success means reconstruction produced data, not that the needle passed validation.",
}, []string{"result"})
VolumeServerEcShardCopyFailures = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemVolumeServer,
Name: "ec_shard_copy_failures_total",
Help: "Counter of failed EC shard copies into this server by collection and reason.",
}, []string{"collection", "reason"})
S3RequestCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "request_total",
Help: "Counter of s3 requests.",
}, []string{"type", "code", "bucket"})
S3ReadAbortedCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "read_aborted_total",
Help: "Counter of s3 object reads that failed after the response status was sent, by bucket and cause.",
}, []string{"bucket", "cause"})
S3HandlerCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "handler_total",
Help: "Counter of s3 server handlers.",
}, []string{"type"})
S3RequestHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "request_seconds",
Help: "Bucketed histogram of s3 request processing time.",
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 24),
}, []string{"type", "bucket"})
S3TimeToFirstByteHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "time_to_first_byte_millisecond",
Help: "Bucketed histogram of s3 time to first byte request processing time.",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 27),
}, []string{"type", "bucket"})
S3PutStageHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "put_stage_seconds",
Help: "Bucketed histogram of the time one s3 object write spends in each stage: body_read waits on the request body, assign on volume assigns, storage on volume assigns and chunk uploads (the chunked upload apart from body reads), metadata from the uploaded chunks to the committed entry.",
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 24),
}, []string{"operation", "stage"})
S3InFlightRequestsGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "in_flight_requests",
Help: "Current number of in-flight requests being handled by s3.",
}, []string{"type"})
S3InFlightUploadBytesGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "in_flight_upload_bytes",
Help: "Current number of bytes being uploaded to S3.",
})
S3InFlightUploadCountGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "in_flight_upload_count",
Help: "Current number of uploads in progress to S3.",
})
S3BucketTrafficReceivedBytesCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "bucket_traffic_received_bytes_total",
Help: "Total number of bytes received by an S3 bucket from clients.",
}, []string{"bucket"})
S3BucketTrafficSentBytesCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "bucket_traffic_sent_bytes_total",
Help: "Total number of bytes sent from an S3 bucket to clients.",
}, []string{"bucket"})
S3DeletedObjectsCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "deleted_objects",
Help: "Number of objects deleted in each bucket.",
}, []string{"bucket"})
S3UploadedObjectsCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "uploaded_objects",
Help: "Number of objects uploaded in each bucket.",
}, []string{"bucket"})
S3NotificationRecordsCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "notification_records_total",
Help: "Bucket event records per target, counted once when acked by the broker or dropped.",
}, []string{"target", "result"})
S3NotificationRecordsLateCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "notification_records_late_total",
Help: "Bucket event records per target still neither acked nor dropped when their request answered.",
}, []string{"target"})
S3NotificationQueueDepthGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "notification_queue_depth",
Help: "Bucket event records waiting to reach a target's topic.",
}, []string{"target"})
S3NotificationPublishWaitHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "notification_publish_wait_seconds",
Help: "Time a request waited for its bucket event records to be acked.",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 12),
})
S3NotificationDeliveredCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "notification_delivered_records_total",
Help: "Bucket event records a forwarder delivered to its target.",
}, []string{"target"})
S3NotificationSendRetriesCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "notification_send_retries_total",
Help: "Sends to a target that failed and are retried.",
}, []string{"target"})
S3NotificationRetentionGapCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "notification_retention_gap_records_total",
Help: "Bucket event records retention removed from a target's topic before they were delivered.",
}, []string{"target"})
S3NotificationSkippedCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "notification_skipped_records_total",
Help: "Bucket event records a forwarder skipped because they cannot be decoded or rendered.",
}, []string{"target", "reason"})
S3NotificationLagGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "notification_lag_records",
Help: "Undelivered bucket event records the gateway forwarding a target can see: current ranges, ranges held back behind an older generation, and sealed retired ranges; an old range still being sealed after a repartition is not counted.",
}, []string{"target"})
S3BucketSizeBytesGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "bucket_size_bytes",
Help: "Current size of each S3 bucket in bytes (logical size, deduplicated across replicas).",
}, []string{"bucket"})
S3BucketPhysicalSizeBytesGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "bucket_physical_size_bytes",
Help: "Current physical size of each S3 bucket in bytes (including all replicas).",
}, []string{"bucket"})
S3BucketObjectCountGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "bucket_object_count",
Help: "Current number of objects in each S3 bucket (logical count, deduplicated across replicas).",
}, []string{"bucket"})
S3BucketQuotaBytesGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "bucket_quota_bytes",
Help: "Configured quota of each S3 bucket in bytes. Only present for buckets with an enabled quota.",
}, []string{"bucket"})
S3BucketReadOnlyGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3,
Name: "bucket_read_only",
Help: "Whether each S3 bucket is read-only (1) or writable (0), e.g. after exceeding its quota.",
}, []string{"bucket"})
RemoteCacheReadCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemRemote,
Name: "cache_read_total",
Help: "Remote-mount object read attempts by source, bucket and cache result. A cold object retried before caching completes records a miss per attempt; paths outside the buckets folder use bucket \"_other\".",
}, []string{"source", "bucket", "result"})
RemoteCacheEvictedCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemRemote,
Name: "cache_evicted_total",
Help: "Remote-mounted objects whose local chunks were evicted under disk pressure.",
})
UploadErrorCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Name: "upload_error_total",
Help: "Counter of upload errors by HTTP status code. Code 0 means transport error (no response received).",
}, []string{"code"})
S3LifecycleDispatchCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3Lifecycle,
Name: "dispatch_total",
Help: "Counter of LifecycleDelete RPC outcomes by bucket, action kind, and outcome.",
}, []string{"bucket", "kind", "outcome"})
S3LifecycleScheduleDepthGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3Lifecycle,
Name: "schedule_depth",
Help: "Number of pending matches in the dispatcher schedule per shard.",
}, []string{"shard"})
S3LifecycleCursorMinTsNs = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3Lifecycle,
Name: "cursor_min_ts_ns",
Help: "Per-shard min cursor timestamp in nanoseconds since epoch (lag = now - min).",
}, []string{"shard"})
S3LifecycleEventCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3Lifecycle,
Name: "events_total",
Help: "Counter of meta-log events the reader emitted to the router, partitioned by shard.",
}, []string{"shard"})
S3LifecycleBootstrapDispatchCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3Lifecycle,
Name: "bootstrap_dispatch_total",
Help: "Counter of bootstrap-walk Delete dispatches by bucket and action kind.",
}, []string{"bucket", "kind"})
// S3LifecycleMetadataOnlyCounter counts successful LifecycleDelete
// dispatches that took the metadata-only path — entry was removed
// without per-chunk DeleteFile RPCs because the entry's Attributes
// .TtlSec > 0 and the volume's natural TTL will reclaim chunks. Per-
// rule cardinality (rule_hash hex-encoded) lets operators identify
// which specific rule is exercising the optimization; in clusters
// with many rules this can be reduced via Prometheus relabeling.
S3LifecycleMetadataOnlyCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3Lifecycle,
Name: "metadata_only_total",
Help: "Counter of LifecycleDelete completions that skipped per-chunk delete (volume TTL reclaim).",
}, []string{"bucket", "rule_hash"})
// S3LifecycleDispatchLimiterWaitSeconds is the cluster-wide rate
// limiter's per-dispatch wait time on the daily-replay path. The
// limiter blocks just before each LifecycleDelete RPC; near-zero
// observations mean the cluster cap isn't binding, a long-tail at
// the configured 1/rate ceiling means the cluster cap is the
// active throttle. Operators tune cluster_deletes_per_second by
// reading p95/p99 on this histogram.
S3LifecycleDispatchLimiterWaitSeconds = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemS3Lifecycle,
Name: "dispatch_limiter_wait_seconds",
Help: "Time spent waiting on the cluster rate limiter before issuing a LifecycleDelete RPC. Non-zero values indicate the cluster cap is binding.",
Buckets: []float64{0.0001, 0.001, 0.01, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10},
})
S3LifecycleDailyRunShardDurationSeconds = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemS3Lifecycle,
Name: "daily_run_shard_duration_seconds",
Help: "Wall-clock seconds spent in one shard's daily_replay pass. p95 climbing toward MaxRuntime means the shard is brushing its budget.",
Buckets: []float64{0.1, 0.5, 1, 5, 15, 60, 300, 900, 1800, 3600},
}, []string{"shard"})
S3LifecycleDailyRunEventsScanned = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemS3Lifecycle,
Name: "daily_run_events_scanned_total",
Help: "Counter of meta-log events drainShardEvents processed on the daily_replay path, partitioned by shard.",
}, []string{"shard"})
// S3LifecycleDailyRunLastWalkedNs is the per-shard wall-clock
// timestamp (UnixNano) of the most recent successful steady-state /
// empty-replay walker fire. Set by dailyrun.runShard after each
// cursor save. Zero means the shard hasn't completed a walk yet
// (either cold start, or the walker never fired because the bucket
// has only replay-eligible rules and the throttle hasn't elapsed).
// Operators read (now - last_walked_ns) to confirm the walker
// cadence matches WalkerInterval; a stuck value means the
// scheduler isn't invoking the worker, the throttle is too long,
// or the walker is failing.
S3LifecycleDailyRunLastWalkedNs = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3Lifecycle,
Name: "daily_run_last_walked_ns",
Help: "Per-shard timestamp (UnixNano) of the most recent successful walker fire. 0 means the shard hasn't completed a walk yet.",
}, []string{"shard"})
// S3LifecycleDailyRunLastFullPassTimestampSeconds is when the last
// lifecycle pass that covered every shard and every lifecycle policy
// without an error finished. Partial, failed and cancelled passes leave
// it alone, unlike the per-shard cursor and walk gauges.
S3LifecycleDailyRunLastFullPassTimestampSeconds = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemS3Lifecycle,
Name: "daily_run_last_full_pass_timestamp_seconds",
Help: "Unix time the last fully successful lifecycle pass finished. 0 means none is known yet.",
})
AdminMaintenanceTasksByStatus = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemAdmin,
Name: "maintenance_tasks_by_status",
Help: "Current number of maintenance tasks by status (pending, assigned, in_progress, completed, failed, cancelled).",
}, []string{"status"})
AdminMaintenanceTasksByType = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemAdmin,
Name: "maintenance_tasks_by_type",
Help: "Current number of maintenance tasks by type.",
}, []string{"type"})
AdminMaintenanceTasksCompletedTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemAdmin,
Name: "maintenance_tasks_completed_total",
Help: "Counter of maintenance tasks that reached a terminal state, by type and outcome (completed, failed).",
}, []string{"type", "outcome"})
AdminMaintenanceTaskDurationSeconds = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: subsystemAdmin,
Name: "maintenance_task_duration_seconds",
Help: "Execution time of maintenance tasks that reached a terminal state, by type.",
Buckets: prometheus.ExponentialBuckets(1, 2, 16),
}, []string{"type"})
AdminMaintenanceLastScanTimestampSeconds = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemAdmin,
Name: "maintenance_last_scan_timestamp_seconds",
Help: "Unix timestamp of the most recent maintenance scan. 0 means no scan has run yet.",
})
AdminMaintenanceNextScanTimestampSeconds = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemAdmin,
Name: "maintenance_next_scan_timestamp_seconds",
Help: "Unix timestamp of the next expected maintenance scan.",
})
AdminWorkersConnected = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemAdmin,
Name: "workers_connected",
Help: "Current number of maintenance workers known to the admin server.",
})
AdminWorkerSlots = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: subsystemAdmin,
Name: "worker_slots",
Help: "Maintenance worker task slots aggregated across workers, by state (used, max).",
}, []string{"state"})
AdminWorkerEventsTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: subsystemAdmin,
Name: "worker_events_total",
Help: "Counter of maintenance worker lifecycle events by type (registered, unregistered, stale_removed).",
}, []string{"event"})
)
func init() {
Gather.MustRegister(BuildInfo)
Gather.MustRegister(MasterStartTimeSeconds)
Gather.MustRegister(MasterClientConnectCounter)
Gather.MustRegister(MasterRaftIsleader)
Gather.MustRegister(MasterAdminLock)
Gather.MustRegister(MasterVolumeGrowthFrozen)
Gather.MustRegister(MasterDuplicateVolumeIds)
Gather.MustRegister(MasterReceivedHeartbeatCounter)
Gather.MustRegister(MasterLeaderChangeCounter)
Gather.MustRegister(MasterReplicaPlacementMismatch)
Gather.MustRegister(MasterVolumeLayoutWritable)
Gather.MustRegister(MasterVolumeLayoutCrowded)
Gather.MustRegister(MasterPickForWriteErrorCounter)
Gather.MustRegister(MasterBroadcastToFullErrorCounter)
Gather.MustRegister(FilerRequestCounter)
Gather.MustRegister(FilerHandlerCounter)
Gather.MustRegister(FilerRequestHistogram)
Gather.MustRegister(FilerInFlightRequestsGauge)
Gather.MustRegister(FilerGrpcRequestCounter)
Gather.MustRegister(FilerGrpcRequestHistogram)
Gather.MustRegister(FilerInFlightUploadBytesGauge)
Gather.MustRegister(FilerInFlightUploadCountGauge)
Gather.MustRegister(FilerStoreCounter)
Gather.MustRegister(FilerStoreHistogram)
Gather.MustRegister(FilerRemoteDeletionTombstones)
Gather.MustRegister(FilerRemoteDeletionTombstonesFull)
Gather.MustRegister(FilerSyncOffsetGauge)
Gather.MustRegister(FilerSyncEventsReceivedCounter)
Gather.MustRegister(FilerSyncEventsProcessedCounter)
Gather.MustRegister(FilerSyncEventsFailedCounter)
Gather.MustRegister(FilerSyncInFlightJobsGauge)
Gather.MustRegister(FilerSyncLagSecondsGauge)
Gather.MustRegister(FilerSyncReceivedBytesCounter)
Gather.MustRegister(FilerSyncProcessedBytesCounter)
Gather.MustRegister(FilerSyncFailedBytesCounter)
Gather.MustRegister(FilerSyncInFlightBytesGauge)
Gather.MustRegister(FilerServerLastSendTsOfSubscribeGauge)
Gather.MustRegister(FilerSubscribeGapStalledGauge)
Gather.MustRegister(FilerSubscribeUnprovenGapCrossings)
Gather.MustRegister(FilerSubscribeWatermarkHolds)
Gather.MustRegister(FilerSubscribeDeliveryLagSeconds)
Gather.MustRegister(FilerSubscribeHoldSeconds)
Gather.MustRegister(FilerSubscribeResumeFromDisk)
Gather.MustRegister(FilerMetaDeliveryClaimAgeSeconds)
Gather.MustRegister(FilerMetaPeerLowWatermarkAgeSeconds)
Gather.MustRegister(FilerMetaAggregatorReplayFailures)
Gather.MustRegister(FilerObjectSizeBytesHistogram)
Gather.MustRegister(collectors.NewGoCollector())
Gather.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}))
Gather.MustRegister(VolumeServerStartTimeSeconds)
Gather.MustRegister(VolumeServerRequestCounter)
Gather.MustRegister(VolumeServerHandlerCounter)
Gather.MustRegister(VolumeServerRequestHistogram)
Gather.MustRegister(VolumeServerInFlightRequestsGauge)
Gather.MustRegister(VolumeServerVacuumingCompactCounter)
Gather.MustRegister(VolumeServerVacuumingCommitCounter)
Gather.MustRegister(VolumeServerVacuumingHistogram)
Gather.MustRegister(VolumeServerVacuumingDroppedNeedlesCounter)
Gather.MustRegister(VolumeServerVolumeGauge)
Gather.MustRegister(VolumeServerMaxVolumeCounter)
Gather.MustRegister(VolumeServerReadOnlyVolumeGauge)
Gather.MustRegister(VolumeServerEcShardDiskMismatchGauge)
Gather.MustRegister(VolumeServerDiskSizeGauge)
Gather.MustRegister(VolumeServerResourceGauge)
Gather.MustRegister(VolumeServerDiskErrorGauge)
Gather.MustRegister(VolumeServerStorageIoErrorCounter)
Gather.MustRegister(VolumeServerIoQuarantineGauge)
Gather.MustRegister(VolumeServerConcurrentDownloadLimit)
Gather.MustRegister(VolumeServerConcurrentUploadLimit)
Gather.MustRegister(VolumeServerInFlightDownloadSize)
Gather.MustRegister(VolumeServerInFlightUploadSize)
Gather.MustRegister(VolumeServerMasterDisconnections)
Gather.MustRegister(VolumeServerFileReadFailures)
Gather.MustRegister(VolumeServerFileReadInvalidNeedles)
Gather.MustRegister(VolumeServerFileWriteFailures)
Gather.MustRegister(VolumeServerScrubLastTimeSeconds)
Gather.MustRegister(VolumeServerScrubVolumeFailures)
Gather.MustRegister(VolumeServerScrubShardFailures)
Gather.MustRegister(VolumeServerReplicationCounter)
Gather.MustRegister(VolumeServerReplicationHistogram)
Gather.MustRegister(VolumeServerReplicationTargets)
Gather.MustRegister(VolumeServerReplicationFailures)
Gather.MustRegister(VolumeServerECRebuildHistogram)
Gather.MustRegister(VolumeServerECRebuildCounter)
Gather.MustRegister(VolumeServerECReconstructedIntervalCounter)
Gather.MustRegister(VolumeServerEcShardCopyFailures)
Gather.MustRegister(MasterUnderReplicatedVolumes)
Gather.MustRegister(MasterWritableVolumesPerDisk)
Gather.MustRegister(MasterVolumeCreationCounter)
Gather.MustRegister(S3RequestCounter)
Gather.MustRegister(S3ReadAbortedCounter)
Gather.MustRegister(S3HandlerCounter)
Gather.MustRegister(S3RequestHistogram)
Gather.MustRegister(S3InFlightRequestsGauge)
Gather.MustRegister(S3InFlightUploadBytesGauge)
Gather.MustRegister(S3InFlightUploadCountGauge)
Gather.MustRegister(S3TimeToFirstByteHistogram)
Gather.MustRegister(S3PutStageHistogram)
Gather.MustRegister(S3BucketTrafficReceivedBytesCounter)
Gather.MustRegister(S3BucketTrafficSentBytesCounter)
Gather.MustRegister(S3DeletedObjectsCounter)
Gather.MustRegister(S3UploadedObjectsCounter)
Gather.MustRegister(S3NotificationRecordsCounter)
Gather.MustRegister(S3NotificationRecordsLateCounter)
Gather.MustRegister(S3NotificationQueueDepthGauge)
Gather.MustRegister(S3NotificationPublishWaitHistogram)
Gather.MustRegister(S3NotificationDeliveredCounter)
Gather.MustRegister(S3NotificationSendRetriesCounter)
Gather.MustRegister(S3NotificationRetentionGapCounter)
Gather.MustRegister(S3NotificationSkippedCounter)
Gather.MustRegister(S3NotificationLagGauge)
Gather.MustRegister(S3BucketSizeBytesGauge)
Gather.MustRegister(S3BucketPhysicalSizeBytesGauge)
Gather.MustRegister(S3BucketObjectCountGauge)
Gather.MustRegister(S3BucketQuotaBytesGauge)
Gather.MustRegister(S3BucketReadOnlyGauge)
Gather.MustRegister(RemoteCacheReadCounter)
Gather.MustRegister(RemoteCacheEvictedCounter)
Gather.MustRegister(S3LifecycleDispatchCounter)
Gather.MustRegister(S3LifecycleScheduleDepthGauge)
Gather.MustRegister(S3LifecycleCursorMinTsNs)
Gather.MustRegister(S3LifecycleEventCounter)
Gather.MustRegister(S3LifecycleBootstrapDispatchCounter)
Gather.MustRegister(S3LifecycleMetadataOnlyCounter)
Gather.MustRegister(S3LifecycleDispatchLimiterWaitSeconds)
Gather.MustRegister(S3LifecycleDailyRunShardDurationSeconds)
Gather.MustRegister(S3LifecycleDailyRunEventsScanned)
Gather.MustRegister(S3LifecycleDailyRunLastWalkedNs)
Gather.MustRegister(S3LifecycleDailyRunLastFullPassTimestampSeconds)
Gather.MustRegister(UploadErrorCounter)
Gather.MustRegister(AdminMaintenanceTasksByStatus)
Gather.MustRegister(AdminMaintenanceTasksByType)
Gather.MustRegister(AdminMaintenanceTasksCompletedTotal)
Gather.MustRegister(AdminMaintenanceTaskDurationSeconds)
Gather.MustRegister(AdminMaintenanceLastScanTimestampSeconds)
Gather.MustRegister(AdminMaintenanceNextScanTimestampSeconds)
Gather.MustRegister(AdminWorkersConnected)
Gather.MustRegister(AdminWorkerSlots)
Gather.MustRegister(AdminWorkerEventsTotal)
go bucketMetricTTLControl()
}
func LoopPushingMetric(name, instance, addr string, intervalSeconds int) {
if addr == "" || intervalSeconds == 0 {
return
}
glog.V(0).Infof("%s server sends metrics to %s every %d seconds", name, addr, intervalSeconds)
pusher := push.New(addr, name).Gatherer(Gather).Grouping("instance", instance)
for {
err := pusher.Push()
if err != nil && !strings.HasPrefix(err.Error(), "unexpected status code 200") {
glog.V(0).Infof("could not push metrics to prometheus push gateway %s: %v", addr, err)
}
if intervalSeconds <= 0 {
intervalSeconds = 15
}
time.Sleep(time.Duration(intervalSeconds) * time.Second)
}
}
func JoinHostPort(host string, port int) string {
portStr := strconv.Itoa(port)
if strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]") {
return host + ":" + portStr
}
return net.JoinHostPort(host, portStr)
}
func StartMetricsServer(ip string, port int) {
if port == 0 {
return
}
http.Handle("/metrics", promhttp.HandlerFor(Gather, promhttp.HandlerOpts{}))
glog.Fatal(http.ListenAndServe(JoinHostPort(ip, port), nil))
}
func SourceName(port uint32) string {
hostname, err := os.Hostname()
if err != nil {
return "unknown"
}
return net.JoinHostPort(hostname, strconv.Itoa(int(port)))
}
func RecordBucketActiveTime(bucket string) {
bucketLastActiveLock.Lock()
bucketLastActiveTsNs[bucket] = time.Now().UnixNano()
bucketLastActiveLock.Unlock()
}
func RecordRemoteCacheRead(source, bucket string, hit bool) {
if bucket == "" {
bucket = "_other"
}
result := RemoteCacheResultMiss
if hit {
result = RemoteCacheResultHit
}
RemoteCacheReadCounter.WithLabelValues(source, bucket, result).Inc()
}
func DeleteBucketMetrics(bucket string) {
bucketLastActiveLock.Lock()
delete(bucketLastActiveTsNs, bucket)
bucketLastActiveLock.Unlock()
labels := prometheus.Labels{"bucket": bucket}
c := S3RequestCounter.DeletePartialMatch(labels)
c += S3ReadAbortedCounter.DeletePartialMatch(labels)
c += S3RequestHistogram.DeletePartialMatch(labels)
c += S3TimeToFirstByteHistogram.DeletePartialMatch(labels)
c += S3BucketTrafficReceivedBytesCounter.DeletePartialMatch(labels)
c += S3BucketTrafficSentBytesCounter.DeletePartialMatch(labels)
c += S3DeletedObjectsCounter.DeletePartialMatch(labels)
c += S3UploadedObjectsCounter.DeletePartialMatch(labels)
c += S3BucketSizeBytesGauge.DeletePartialMatch(labels)
c += S3BucketPhysicalSizeBytesGauge.DeletePartialMatch(labels)
c += S3BucketObjectCountGauge.DeletePartialMatch(labels)
c += S3BucketQuotaBytesGauge.DeletePartialMatch(labels)
c += S3BucketReadOnlyGauge.DeletePartialMatch(labels)
c += S3LifecycleDispatchCounter.DeletePartialMatch(labels)
c += S3LifecycleBootstrapDispatchCounter.DeletePartialMatch(labels)
c += S3LifecycleMetadataOnlyCounter.DeletePartialMatch(labels)
c += RemoteCacheReadCounter.DeletePartialMatch(labels)
glog.V(0).Infof("delete bucket metrics, %s: %d", bucket, c)
}
func DeleteCollectionMetrics(collection string) {
labels := prometheus.Labels{"collection": collection}
c := MasterReplicaPlacementMismatch.DeletePartialMatch(labels)
c += MasterVolumeLayoutWritable.DeletePartialMatch(labels)
c += MasterVolumeLayoutCrowded.DeletePartialMatch(labels)
c += MasterUnderReplicatedVolumes.DeletePartialMatch(labels)
c += MasterWritableVolumesPerDisk.DeletePartialMatch(labels)
c += VolumeServerDiskSizeGauge.DeletePartialMatch(labels)
c += VolumeServerVolumeGauge.DeletePartialMatch(labels)
c += VolumeServerReadOnlyVolumeGauge.DeletePartialMatch(labels)
glog.V(0).Infof("delete collection metrics, %s: %d", collection, c)
}
// DeleteVolumeServerCollectionMetrics drops a collection's volume server series
// once its last volume leaves this server. These gauges are only ever set for
// collections still present, so the values from the heartbeat that saw the last
// volume would otherwise stand until the process restarts.
func DeleteVolumeServerCollectionMetrics(collection string) {
VolumeServerDiskSizeGauge.DeleteLabelValues(collection, "normal")
VolumeServerDiskSizeGauge.DeleteLabelValues(collection, "deleted_bytes")
VolumeServerReadOnlyVolumeGauge.DeletePartialMatch(prometheus.Labels{"collection": collection})
}
func bucketMetricTTLControl() {
ttlNs := bucketAtiveTTL.Nanoseconds()
for {
now := time.Now().UnixNano()
// Collect expired buckets under the lock, then release before
// doing the expensive Prometheus DeletePartialMatch calls.
// This prevents blocking RecordBucketActiveTime during cleanup.
bucketLastActiveLock.Lock()
var expiredBuckets []string
for bucket, ts := range bucketLastActiveTsNs {
if (now - ts) > ttlNs {
expiredBuckets = append(expiredBuckets, bucket)
delete(bucketLastActiveTsNs, bucket)
}
}
bucketLastActiveLock.Unlock()
for _, bucket := range expiredBuckets {
labels := prometheus.Labels{"bucket": bucket}
// Only delete gauges and histograms, which represent current state.
// Counters (traffic, requests, objects) must persist for the process
// lifetime so that Prometheus rate()/increase() queries work correctly.
c := S3RequestHistogram.DeletePartialMatch(labels)
c += S3TimeToFirstByteHistogram.DeletePartialMatch(labels)
c += S3BucketSizeBytesGauge.DeletePartialMatch(labels)
c += S3BucketPhysicalSizeBytesGauge.DeletePartialMatch(labels)
c += S3BucketObjectCountGauge.DeletePartialMatch(labels)
c += S3BucketQuotaBytesGauge.DeletePartialMatch(labels)
c += S3BucketReadOnlyGauge.DeletePartialMatch(labels)
glog.V(0).Infof("delete inactive bucket metrics, %s: %d", bucket, c)
}
time.Sleep(bucketAtiveTTL)
}
}
// UpdateBucketSizeMetrics updates the bucket size gauges
// logicalSize is the deduplicated size (accounting for replication)
// physicalSize is the raw size including all replicas
// objectCount is the number of objects in the bucket (deduplicated)
func UpdateBucketSizeMetrics(bucket string, logicalSize, physicalSize float64, objectCount float64) {
S3BucketSizeBytesGauge.WithLabelValues(bucket).Set(logicalSize)
S3BucketPhysicalSizeBytesGauge.WithLabelValues(bucket).Set(physicalSize)
S3BucketObjectCountGauge.WithLabelValues(bucket).Set(objectCount)
RecordBucketActiveTime(bucket)
}
// ResetBucketSizeMetrics drops the size, object count, quota and read-only series of every bucket.
func ResetBucketSizeMetrics() {
S3BucketSizeBytesGauge.Reset()
S3BucketPhysicalSizeBytesGauge.Reset()
S3BucketObjectCountGauge.Reset()
S3BucketQuotaBytesGauge.Reset()
S3BucketReadOnlyGauge.Reset()
}
// UpdateBucketQuotaMetrics updates the per-bucket quota gauges. A non-positive
// quota removes the quota series so utilization queries like
// bucket_size_bytes / bucket_quota_bytes only see enforced quotas.
func UpdateBucketQuotaMetrics(bucket string, quota float64, readOnly bool) {
if quota > 0 {
S3BucketQuotaBytesGauge.WithLabelValues(bucket).Set(quota)
} else {
S3BucketQuotaBytesGauge.DeleteLabelValues(bucket)
}
readOnlyValue := float64(0)
if readOnly {
readOnlyValue = 1
}
S3BucketReadOnlyGauge.WithLabelValues(bucket).Set(readOnlyValue)
}