Documentation ¶
Index ¶
- Constants
- func EmitVersion(m Metrics)
- type Blackhole
- func (Blackhole) AddSample(key []string, val float32)
- func (Blackhole) AddSampleWithLabels(key []string, val float32, labels []Label)
- func (Blackhole) EmitKey(key []string, val float32)
- func (Blackhole) IncrCounter(key []string, val float32)
- func (Blackhole) IncrCounterWithLabels(key []string, val float32, labels []Label)
- func (Blackhole) MeasureSince(key []string, start time.Time)
- func (Blackhole) MeasureSinceWithLabels(key []string, start time.Time, labels []Label)
- func (Blackhole) SetGauge(key []string, val float32)
- func (Blackhole) SetGaugeWithLabels(key []string, val float32, labels []Label)
- type CallCounter
- type DogStatsdConfig
- type FileConfig
- type InMem
- type Label
- type M3Config
- type Metrics
- type MetricsConfig
- type MetricsImpl
- func (m *MetricsImpl) AddSample(key []string, val float32)
- func (m *MetricsImpl) AddSampleWithLabels(key []string, val float32, labels []Label)
- func (m *MetricsImpl) EmitKey(key []string, val float32)
- func (m *MetricsImpl) IncrCounter(key []string, val float32)
- func (m *MetricsImpl) IncrCounterWithLabels(key []string, val float32, labels []Label)
- func (m *MetricsImpl) ListenAndServe(ctx context.Context) error
- func (m *MetricsImpl) MeasureSince(key []string, start time.Time)
- func (m *MetricsImpl) MeasureSinceWithLabels(key []string, start time.Time, labels []Label)
- func (m *MetricsImpl) SetGauge(key []string, val float32)
- func (m *MetricsImpl) SetGaugeWithLabels(key []string, val float32, labels []Label)
- type PrometheusConfig
- type Sink
- type StatsdConfig
Constants ¶
const ( // Action functionality related to actions themselves, such as rate-limiting an action Action = "action" // Activate functionality related to activating some element (such as X509 CA manager); // should be used with other tags to add clarity Activate = "activate" // Append functionality related to appending some element (such as part of a bundle); // should be used with other tags to add clarity Append = "append" // Attest functionality related to attesting; should be used with other tags // to add clarity Attest = "attest" // Create functionality related to creating some entity; should be used with other tags // to add clarity Create = "create" // Create if not exists functionality related to creating some entity; should be used with // other tags to add clarity CreateIfNotExists = "create_if_not_exists" // Delete functionality related to deleting some entity; should be used with other tags // to add clarity Delete = "delete" // Fetch functionality related to fetching some entity; should be used with other tags // to add clarity Fetch = "fetch" // List functionality related to listing some objects; should be used // with other tags to add clarity List = "list" // Prepare functionality related to preparation of some entity; should be used with other tags // to add clarity Prepare = "prepare" // Prune functionality related to pruning some entity(ies); should be used with other tags // to add clarity Prune = "prune" // Push functionality related to pushing some entity to let a destination know // that some source generated such entity; should be used with other tags // to add clarity Push = "push" // Rotate functionality related to rotation of SVID; should be used with other tags // to add clarity Rotate = "rotate" // Set functionality related to set/override/clobber of an entity, such as a bundle; // should be used with other tags to add clarity Set = "set" // Sign functionality related to signing a token / cert; should be used with other tags // to add clarity Sign = "sign" // Sync functionality for syncing (such as CA manager updates). Should // be used with other tags to add clarity Sync = "sync" // Update functionality related to updating some entity; should be used // with other tags to add clarity Update = "update" // Mint functionality related to minting identities Mint = "mint" )
Action metric tags or labels that are typically a specific action
const ( // Address tags some network address Address = "address" // Agent SPIFFE ID AgentID = "agent_id" // Attempt tags some count of attempts Attempt = "attempt" // Audience tags some audience for a token Audience = "audience" // CallerID tags an API caller; should be used with other tags // to add clarity CallerID = "caller_id" // CGroupPath tags a linux CGroup path, most likely for use in attestation CGroupPath = "cgroup_path" // Connection functionality related to some connection; should be used with other tags // to add clarity Connection = "connection" // Connections functionality related to some group of connections; should be used with other tags // to add clarity Connections = "connections" // ContainerID tags some container ID, most likely for use in attestation ContainerID = "container_id" // Count tags some basic count; should be used with other tags and clear messaging to add clarity Count = "count" // CsrSpiffeID represents the SPIFFE ID in a Certificate Signing Request. CsrSpiffeID = "csr_spiffe_id" // DatabaseType labels a database type (MySQL, postgres...) DatabaseType = "db_type" // DiscoveredSelectors tags selectors for some registration DiscoveredSelectors = "discovered_selectors" // DNS name is a name which is resolvable with DNS DNSName = "dns_name" // ElapsedTime tags some duration of time. Reserved for use in telemetry package on // call counters. Exported for tests only. ElapsedTime = "elapsed_time" // Error tag for some error that occurred. Limited usage, such as logging errors at // non-error level. Error = "error" // Expect tags an expected value, as opposed to the one received. Message should clarify // what kind of value was expected, and a different field should show the received value Expect = "expect" // Expiration tags an expiration time for some entity Expiration = "expiration" // ExpiryCheckDuration tags duration for an expiry check; should be used with other tags // to add clarity ExpiryCheckDuration = "expiry_check_duration" // FederatedAdded labels some count of federated bundles that have been added to an entity FederatedAdded = "fed_add" // FederatedRemoved labels some count of federated bundles that have been removed from an entity FederatedRemoved = "fed_rem" // Generation represents an objection generation (i.e. version) Generation = "generation" // IDType tags some type of ID (eg. registration ID, SPIFFE ID...) IDType = "id_type" // IssuedAt tags an issuance timestamp IssuedAt = "issued_at" // JWT declares JWT-SVID type, clarifying metrics JWT = "jwt" // JWTKeys tags some count or list of JWT Keys. Should NEVER provide the actual keys, use // Key IDs instead. JWTKeys = "jwt_keys" // Kid tags some key ID Kid = "kid" // NodeAttestorType declares the type of node attestation. NodeAttestorType = "node_attestor_type" // Nonce tags some nonce for communication Nonce = "nonce" // ParentID tags parent ID for an entry ParentID = "parent_id" // Path declares some logic path, likely on the file system Path = "path" // Peer ID is the SPIFFE ID of a peer PeerID = "peer_id" // PID declares some process ID PID = "pid" // PluginBuiltIn flags whether or not a plugin is built-in, or tags part of // the loading of built-in plugins PluginBuiltIn = "built-in_plugin" // PluginExternal flags whether or not a plugin is external, or tags part of // the loading of external plugins PluginExternal = "external_plugin" // PluginName tags name of some plugin PluginName = "plugin_name" // PluginService tags single service provided by a plugin PluginService = "plugin_service" // PluginServices tags services provided by a plugin PluginServices = "plugin_services" // PluginType tags type of some plugin PluginType = "plugin_type" // Pruned flagging something has been pruned Pruned = "pruned" // RegistrationID tags some registration entry ID RegistrationID = "entry_id" // Registered flags whether some entity is registered or not; should be // either true or false Registered = "registered" // RegistrationEntry tags a registration entry RegistrationEntry = "registration_entry" // ResourceNames tags some group of resources by name ResourceNames = "resource_names" // RetryInterval tags some interval for retry logic RetryInterval = "retry_interval" // Schema tags database schema version Schema = "schema" // Seconds tags some count of seconds; should be used with other tags and message // to add clarity Seconds = "seconds" // Selector tags some registration selector Selector = "selector" // Selectors tags some group of registration selector Selectors = "selectors" // SelectorsAdded labels some count of selectors that have been added to an entity SelectorsAdded = "selectors_added" // SelectorsRemoved labels some count of selectors that have been removed from an entity SelectorsRemoved = "selectors_removed" // SelfSigned tags whether or not some entity is self-signed SelfSigned = "self_signed" // SendJWTBundleLatency tags latency for sending JWT bundle SendJWTBundleLatency = "send_jwt_bundle_latency" // SerialNumber tags a certificate serial number SerialNumber = "serial_num" // SDSPID tags an SDS PID SDSPID = "sds_pid" // Slot X509 CA Slot ID Slot = "slot" // SPIFFEID tags a SPIFFE ID SPIFFEID = "spiffe_id" // Status tags status of call (OK, or some error), or status of some process Status = "status" // Subject tags some subject (likely a SPIFFE ID, and likely for a token); should be used // with other tags to add clarity Subject = "subject" // SVIDResponseLatency tags latency for SVID response SVIDResponseLatency = "svid_response_latency" // SVIDType tags some type of SVID (eg. X509, JWT) SVIDType = "svid_type" // SVIDUpdated tags that for some entity the SVID was updated SVIDUpdated = "svid_updated" // TTL functionality related to a time-to-live field; should be used // with other tags to add clarity TTL = "ttl" // TrustDomainID tags some trust domain ID TrustDomainID = "trust_domain_id" // Unknown tags some unknown caller, entity, or status Unknown = "unknown" // Updated tags some entity as updated; should be used // with other tags to add clarity Updated = "updated" // UpstreamBundle tags an upstream bundle for an entity UpstreamBundle = "upstream_bundle" // VersionInfo tags some version information VersionInfo = "version_info" // WorkloadAttestation tags call of overall workload attestation WorkloadAttestation = "workload_attestation" // WorkloadAttestor tags call of a workload attestor WorkloadAttestor = "workload_attestor" // X509 declared X509 SVID type, clarifying metrics X509 = "x509" // X509CAs tags some count or list of X509 CAs X509CAs = "x509_cas" )
Attribute metric tags or labels that are typically an attribute of a larger entity or logic path
const ( // AgentSVID tag a node (agent) SVID AgentSVID = "agent_svid" // Attestor tags an attestor plugin/type (eg. gcp, aws...) Attestor = "attestor" // Bundle functionality related to a bundle; should be used with other tags // to add clarity Bundle = "bundle" // BundlesUpdate functionality related to updating bundles BundlesUpdate = "bundles_update" // CA functionality related to some CA; should be used with other tags // to add clarity CA = "ca" // CAManager functionality related to a CA manager CAManager = "ca_manager" // CacheManager functionality related to a cache manager CacheManager = "cache_manager" // Catalog functionality related to plugin catalog Catalog = "catalog" // Datastore functionality related to datastore plugin Datastore = "datastore" // Endpoints functionality related to agent/server endpoints Endpoints = "endpoints" // Entry tag for some stored entry; should be used with other tags such as RegistrationAPI // to add clarity Entry = "entry" // Event tag some event that has occurred, for a notifier, watcher, listener, etc. Event = "event" // ExpiringSVIDs tags expiring SVID count/list ExpiringSVIDs = "expiring_svids" // OutdatedSVIDs tags SVID with outdated attributes count/list OutdatedSVIDs = "outdated_svids" // FederatedBundle functionality related to a federated bundle; should be used // with other tags to add clarity FederatedBundle = "federated_bundle" // JoinToken functionality related to a join token; should be used // with other tags to add clarity JoinToken = "join_token" // JWTKey functionality related to a JWT key; should be used with other tags // to add clarity. Should NEVER actually provide the key itself, use Key ID instead. JWTKey = "jwt_key" // JWTSVID functionality related to a JWT-SVID; should be used with other tags // to add clarity JWTSVID = "jwt_svid" // Limit tags a limit Limit = "limit" // Manager functionality related to a manager (such as CA manager); should be // used with other tags to add clarity Manager = "manager" // Method is the full name of the method invoked Method = "method" // NewSVID functionality related to creation of a new SVID NewSVID = "new_svid" // Node functionality related to a node entity or type; should be used with other tags // to add clarity Node = "node" // Notifier functionality related to some notifying entity; should be used with other tags // to add clarity Notifier = "notifier" // ServerCA functionality related to a server CA; should be used with other tags // to add clarity ServerCA = "server_ca" // SpireAgent typically the entire spire agent service SpireAgent = "spire_agent" // SpireServer typically the entire spire server SpireServer = "spire_server" // SVID functionality related to a SVID; should be used with other tags // to add clarity SVID = "svid" // SVIDRotator functionality related to a SVID rotator SVIDRotator = "svid_rotator" // RegistrationManager functionality related to a registration manager RegistrationManager = "registration_manager" // Telemetry tags a telemetry module Telemetry = "telemetry" // X509CA functionality related to an x509 CA; should be used with other tags // to add clarity X509CA = "x509_ca" // X509CASVID functionality related to an x509 CA SVID; should be used with other tags // to add clarity X509CASVID = "x509_ca_svid" // X509SVID functionality related to an x509 SVID; should be used with other tags // to add clarity X509SVID = "x509_svid" )
Entity metric tags or labels that are typically an entity or module in their own right, rather than descriptive of other entities or modules
const ( // AuthorizeCall functionality related to authorizing an incoming call AuthorizeCall = "authorize_call" // CreateFederatedBundle functionality related to creating a federated bundle CreateFederatedBundle = "create_federated_bundle" // CreateJoinToken functionality related to creating a join token CreateJoinToken = "create_join_token" // CreateRegistrationEntry functionality related to creating a registration entry CreateRegistrationEntry = "create_registration_entry" // CreateRegistrationEntryIfNotExists functionality related to creating a registration entry CreateRegistrationEntryIfNotExists = "create_registration_entry_if_not_exists" // DeleteFederatedBundle functionality related to deleting a federated bundle DeleteFederatedBundle = "delete_federated_bundle" // DeleteRegistrationEntry functionality related to deleting a registration entry DeleteRegistrationEntry = "delete_registration_entry" // EvictAgent funtionality related to evicting an agent EvictAgent = "evict_agent" // FetchBundle functionality related to fetching a CA bundle FetchBundle = "fetch_bundle" // FetchEntriesUpdates functionality related to fetching entries updates; should be used // with other tags to add clarity FetchEntriesUpdates = "fetch_entries_updates" // FetchFederatedBundle functionality related to fetching a federated bundle FetchFederatedBundle = "fetch_federated_bundle" // FetchJWTSVID functionality related to fetching a JWT-SVID FetchJWTSVID = "fetch_jwt_svid" // FetchJWTBundles functionality related to fetching JWT bundles FetchJWTBundles = "fetch_jwt_bundles" // FetchRegistrationEntry functionality related to fetching a registration entry FetchRegistrationEntry = "fetch_registration_entry" // FetchRegistrationEntries functionality related to fetching registration entries FetchRegistrationEntries = "fetch_registration_entries" // FetchSecrets functionality related to fetching secrets FetchSecrets = "fetch_secrets" // FetchSVIDsUpdates functionality related to fetching SVIDs updates; should be used // with other tags to add clarity FetchSVIDsUpdates = "fetch_svids_updates" // FetchX509CASVID functionality related to fetching an X509 SVID FetchX509CASVID = "fetch_x509_ca_svid" // FetchX509SVID functionality related to fetching an X509 SVID FetchX509SVID = "fetch_x509_svid" // GetNodeSelectors functionality related to getting node selectors GetNodeSelectors = "get_node_selectors" // ListAgents functionality related to listing agents ListAgents = "list_agents" // ListAllEntriesWithPages functionality related to listing all registration entries with pagination ListAllEntriesWithPages = "list_all_entries_with_pages" // ListFederatedBundles functionality related to listing federated bundles ListFederatedBundles = "list_federated_bundles" // ListRegistrationsByParentID functionality related to listing registrations by parent ID ListRegistrationsByParentID = "list_registrations_by_parent_id" // ListRegistrationsBySelector functionality related to listing registrations by selector ListRegistrationsBySelector = "list_registrations_by_selector" // ListRegistrationsBySelectors functionality related to listing registrations by selectors ListRegistrationsBySelectors = "list_registrations_by_selectors" // ListRegistrationsBySPIFFEID functionality related to listing registrations by SPIFFE ID ListRegistrationsBySPIFFEID = "list_registrations_by_spiffe_id" // MintJWTSVID functionality related to minting a JWT-SVID MintJWTSVID = "mint_jwt_svid" // MintX509SVID functionality related to minting an X.509 SVID MintX509SVID = "mint_x509_svid" // NodeAPI functionality related to attested/attesting nodes (agents) NodeAPI = "node_api" // PushJWTKeyUpstream functionality related to pushing a public JWT Key to an upstream server. PushJWTKeyUpstream = "push_jwtkey_upstream" // RegistrationAPI functionality related to the registration api; should be used // with other tags to add clarity RegistrationAPI = "registration_api" // SDSAPI functionality related to SDS; should be used with other tags // to add clarity SDSAPI = "sds_api" // StreamSecrets functionality related to streaming secrets StreamSecrets = "stream_secrets" // SubsystemName declares field for some subsystem name (an API, module...) SubsystemName = "subsystem_name" // UpdateFederatedBundle functionality related to updating a federated bundle UpdateFederatedBundle = "update_federated_bundle" // UpdateRegistrationEntry functionality related to updating a registration entry UpdateRegistrationEntry = "update_registration_entry" // ValidateJWTSVID functionality related validating a JWT-SVID ValidateJWTSVID = "validate_jwt_svid" // WorkloadAPI flagging usage of workload API; should be used with other tags // to add clarity WorkloadAPI = "workload_api" )
Operation metric tags or labels that are typically a specific operation or API
Variables ¶
This section is empty.
Functions ¶
func EmitVersion ¶
func EmitVersion(m Metrics)
Types ¶
type Blackhole ¶
type Blackhole struct{}
Blackhole implements the Metrics interface, but throws away the metric data Useful for satisfying the Metrics interface when testing code which depends on it.
func (Blackhole) AddSampleWithLabels ¶
func (Blackhole) IncrCounter ¶
func (Blackhole) IncrCounterWithLabels ¶
func (Blackhole) MeasureSinceWithLabels ¶
type CallCounter ¶
type CallCounter struct {
// contains filtered or unexported fields
}
CallCounter is used to track timing and other information about a "call". It is intended to be scoped to a function with a defer and a named error value, if applicable, like so:
func Foo() (err error) { call := StartCall(metrics, "foo") defer call.Done(&err) call.AddLabel("food", "burgers") }
See `Done` doc for labels automatically added.
Instances of this struct should only be created directly by this package and its subpackages, which define the specific metrics that are emitted. It is left exported for testing purposes.
func StartCall ¶
func StartCall(metrics Metrics, key string, keyn ...string) *CallCounter
StartCall starts a "call", which when finished via Done() will emit timing and error related metrics.
func (*CallCounter) AddLabel ¶
func (c *CallCounter) AddLabel(name, value string)
AddLabel adds a label to be emitted with the call counter. It is safe to call from multiple goroutines.
func (*CallCounter) Done ¶
func (c *CallCounter) Done(errp *error)
Done finishes the "call" and emits metrics. No other calls to the CallCounter should be done during or after the call to Done. In other words, it is not thread-safe and is intended to be the final call to the CallCounter struct. Emits latency and counter metrics, including adding a Status label according to gRPC code of the given error. If nil error, the code is OK (success).
type DogStatsdConfig ¶
type FileConfig ¶
type FileConfig struct { Prometheus *PrometheusConfig `hcl:"Prometheus"` DogStatsd []DogStatsdConfig `hcl:"DogStatsd"` Statsd []StatsdConfig `hcl:"Statsd"` M3 []M3Config `hcl:"M3"` InMem *InMem `hcl:"InMem"` UnusedKeys []string `hcl:",unusedKeys"` }
type Label ¶
type Label = metrics.Label
Label is a label/tag for a metric
func SanitizeLabels ¶
SanitizeLabels sanitize all given labels
type Metrics ¶
type Metrics interface { // A Gauge should retain the last value it is set to SetGauge(key []string, val float32) SetGaugeWithLabels(key []string, val float32, labels []Label) // Should emit a Key/Value pair for each call EmitKey(key []string, val float32) // Counters should accumulate values IncrCounter(key []string, val float32) IncrCounterWithLabels(key []string, val float32, labels []Label) // Samples are for timing information, where quantiles are used AddSample(key []string, val float32) AddSampleWithLabels(key []string, val float32, labels []Label) // A convenience function for measuring elapsed time with a single line MeasureSince(key []string, start time.Time) MeasureSinceWithLabels(key []string, start time.Time, labels []Label) }
Metrics is an interface for all metrics plugins and services
func WithLabels ¶
type MetricsConfig ¶
type MetricsConfig struct { FileConfig FileConfig Logger logrus.FieldLogger ServiceName string Sinks []Sink }
type MetricsImpl ¶
type MetricsImpl struct { *metrics.Metrics // contains filtered or unexported fields }
func NewMetrics ¶
func NewMetrics(c *MetricsConfig) (*MetricsImpl, error)
NewMetrics returns a Metric implementation
func (*MetricsImpl) AddSample ¶
func (m *MetricsImpl) AddSample(key []string, val float32)
func (*MetricsImpl) AddSampleWithLabels ¶
func (m *MetricsImpl) AddSampleWithLabels(key []string, val float32, labels []Label)
AddSampleWithLabels delegates to embedded metrics, sanitizing labels
func (*MetricsImpl) EmitKey ¶
func (m *MetricsImpl) EmitKey(key []string, val float32)
func (*MetricsImpl) IncrCounter ¶
func (m *MetricsImpl) IncrCounter(key []string, val float32)
func (*MetricsImpl) IncrCounterWithLabels ¶
func (m *MetricsImpl) IncrCounterWithLabels(key []string, val float32, labels []Label)
IncrCounterWithLabels delegates to embedded metrics, sanitizing labels
func (*MetricsImpl) ListenAndServe ¶
func (m *MetricsImpl) ListenAndServe(ctx context.Context) error
ListenAndServe starts the metrics process
func (*MetricsImpl) MeasureSince ¶
func (m *MetricsImpl) MeasureSince(key []string, start time.Time)
func (*MetricsImpl) MeasureSinceWithLabels ¶
func (m *MetricsImpl) MeasureSinceWithLabels(key []string, start time.Time, labels []Label)
MeasureSinceWithLabels delegates to embedded metrics, sanitizing labels
func (*MetricsImpl) SetGauge ¶
func (m *MetricsImpl) SetGauge(key []string, val float32)
func (*MetricsImpl) SetGaugeWithLabels ¶
func (m *MetricsImpl) SetGaugeWithLabels(key []string, val float32, labels []Label)
SetGaugeWithLabels delegates to embedded metrics, sanitizing labels