Documentation
¶
Index ¶
- Constants
- func Zero[T any]() T
- type BasicAuth
- type Callback
- type CallbackHook
- type CategoryStats
- type ConnectionConfig
- type Data
- type DataHandle
- type Datum
- type FileFormat
- type FileStorage
- type Mailbox
- type Marshaller
- type MetadataDatum
- type MetricDatum
- type NetworkClient
- type NetworkStats
- type NotificationRelease
- type ParallelismConfig
- type ParralelismStats
- type PrometheusMarshaller
- type PrometheusMetric
- type PrometheusSerializer
- type RequestMoreSignals
- type Serializer
- type SerializerConfig
- type SerializerStats
- type StatsHub
- type SyncMailbox
- type Type
- type Unmarshaller
Constants ¶
const AlloyFileVersionV1 = FileFormat("alloy.metrics.queue.v1")
const AlloyFileVersionV2 = FileFormat("alloy.metrics.queue.v2")
const PrometheusMetadataV1 = Type("prometheus.metadata.v1")
PrometheusMetadataV1 corresponds to prompb.MetricMetadata byte format.
const PrometheusMetricV1 = Type("prometheus.metric.v1")
PrometheusMetricV1 corresponds to prompb.TimeSeries byte format.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CallbackHook ¶
type CategoryStats ¶
type ConnectionConfig ¶
type ConnectionConfig struct { // URL is the URL of the Prometheus server. URL string // BasicAuth holds the username and password for basic HTTP authentication. BasicAuth *BasicAuth // BearerToken is the bearer token for the Prometheus server. BearerToken string // UserAgent is the User-Agent header sent to the Prometheus server. UserAgent string // Timeout specifies the duration for which the connection will wait for a response before timing out. Timeout time.Duration // RetryBackoff is the duration between retries when a network request fails. // The next retry will happen after RetryBackoff + (RetryBackoff * attempt number). RetryBackoff time.Duration // MaxRetryAttempts specifies the maximum number of times a request will be retried // if it fails. The next retry will happen after RetryBackoff + (RetryBackoff * attempt number). // If this is set to 0, no retries are attempted. MaxRetryAttempts uint // BatchCount is the number of time series to batch together before sending to the network. BatchCount int // FlushInterval specifies the duration between each flush of the network // buffer. If no data is available, the buffer is not flushed. FlushInterval time.Duration // ExternalLabels specifies the external labels to be added to all samples // sent to the Prometheus server. ExternalLabels map[string]string // Headers specifies the HTTP headers to be added to all requests // sent to the server. Headers map[string]string // ProxyURL is the URL of the HTTP proxy to use for requests. // If empty, no proxy is used. ProxyURL string // ProxyFromEnvironment determines whether to read proxy configuration from environment // variables HTTP_PROXY, HTTPS_PROXY and NO_PROXY. // If true, environment proxy settings will be used even if ProxyURL is set. ProxyFromEnvironment bool // ProxyConnectHeaders specify the headers to send to proxies during CONNECT requests. ProxyConnectHeaders map[string]string // TLSCert is the PEM-encoded certificate string for TLS client authentication TLSCert string // TLSKey is the PEM-encoded private key string for TLS client authentication TLSKey string // TLSCACert is the PEM-encoded CA certificate string for server verification TLSCACert string // InsecureSkipVerify controls whether the client verifies the server's certificate chain and host name InsecureSkipVerify bool // UseRoundRobin UseRoundRobin bool // ParallelismConfig determines how many concurrent connections to have. Parallelism ParallelismConfig }
ConnectionConfig holds configuration details for network connections. It includes various options such as authentication, timeouts, retry policies, batching, and connection management settings.
func (ConnectionConfig) ToPrometheusConfig ¶
func (cc ConnectionConfig) ToPrometheusConfig() (config.HTTPClientConfig, error)
ToPrometheusConfig converts a ConnectionConfig to a config.HTTPClientConfig and returns any error encountered
type DataHandle ¶
type Datum ¶
type Datum interface { // Bytes represents the underlying data and should only be used in conjunction with the type. Bytes() []byte Type() Type FileFormat() FileFormat // Free datums are often pooled and this should be called when the datum is no longer needed. Free() }
Datum represent one item of data.
type FileFormat ¶
type FileFormat string
type FileStorage ¶
type Mailbox ¶
type Mailbox[T any] struct { // contains filtered or unexported fields }
Mailbox is a backwards compatible implemention of the actor mailbox. It uses chann underneath the hood that mimics the behavior of actor mailboxes.
type Marshaller ¶
type Marshaller interface { // Marshal handler passes in the buffer to be written. The buffer is only valid for the lifecycle of the function call. // Metadata is passed via the map and should be encoded into the underlying storage. The same keys and values should be returned // on Deserialize. Marshal(handle func(map[string]string, []byte) error) error }
Marshaller provides the ability to write for a given schema defined by the FileFormat. These are NOT threadsafe.
type MetadataDatum ¶
type MetricDatum ¶
type NetworkClient ¶
type NetworkStats ¶
type NetworkStats struct { Series CategoryStats Histogram CategoryStats Metadata CategoryStats SendDuration time.Duration NewestTimestampSeconds int64 SeriesBytes int MetadataBytes int }
func (NetworkStats) Total429 ¶
func (ns NetworkStats) Total429() int
func (NetworkStats) Total5XX ¶
func (ns NetworkStats) Total5XX() int
func (NetworkStats) TotalFailed ¶
func (ns NetworkStats) TotalFailed() int
func (NetworkStats) TotalRetried ¶
func (ns NetworkStats) TotalRetried() int
func (NetworkStats) TotalSent ¶
func (ns NetworkStats) TotalSent() int
type NotificationRelease ¶
type NotificationRelease func()
type ParallelismConfig ¶
type ParallelismConfig struct { // AllowedDrift is the maximum amount of time that is allowed for the Newest Timestamp Serializer - Newest Timestamp Sent via Network before the connections scales up. // If Newest TS In Serializer sees 100s and Newest TS Out Network sees 20s then we have a drift of 80s. If AllowedDrift is 60s that would // trigger a scaling up event. AllowedDrift time.Duration // MinimumScaleDownDrift is the amount if we go below that we can scale down. Using the above if In is 100s and Out is 70s and MinimumScaleDownDrift is 30 then we wont scale // down even though we are below the 60s. This is to keep the number of connections from flapping. In practice we should consider 30s MinimumScaleDownDrift and 60s AllowedDrift to be a sweet spot // for general usage. MinimumScaleDownDrift time.Duration // MaxConnections is the maximum number of concurrent connections to use. MaxConnections uint // MinConnections is the minimum number of concurrent connections to use. MinConnections uint // ResetInterval is how long to keep network successes and errors in memory for calculations. ResetInterval time.Duration // Lookback is how far to lookback for previous desired values. This is to prevent flapping. // In a situation where in the past 5 minutes you have desired [1,2,1,1] and desired is 1 it will // choose 2 since that was the greatest. This determines how fast you can scale down. Lookback time.Duration // CheckInterval is how long to check for desired values. CheckInterval time.Duration // AllowedNetworkErrorFraction is the fraction of failed network requests that are allowable. This will // trigger a decrease in connections if exceeded. AllowedNetworkErrorFraction float64 }
type ParralelismStats ¶
type PrometheusMarshaller ¶
type PrometheusMarshaller interface { Marshaller // AddPrometheusMetric adds a metric to the list of metrics. External Labels are passed in and added to the raw byte representation. // They are not added to lbls since that array may not be owned by the caller. Metric labels will override external labels. AddPrometheusMetric(ts int64, value float64, lbls labels.Labels, h *histogram.Histogram, fh *histogram.FloatHistogram, e exemplar.Exemplar, externalLabels map[string]string) error AddPrometheusMetadata(name string, unit string, help string, pType string) error }
type PrometheusMetric ¶
type PrometheusSerializer ¶
type RequestMoreSignals ¶
type RequestMoreSignals[T Datum] struct { Response chan []T }
type Serializer ¶
type Serializer interface { Start(ctx context.Context) error Stop() UpdateConfig(ctx context.Context, cfg SerializerConfig) (bool, error) }
Serializer handles converting a set of signals into a binary representation to be written to storage.
type SerializerConfig ¶
type SerializerStats ¶
type StatsHub ¶
type StatsHub interface { SendSeriesNetworkStats(NetworkStats) SendSerializerStats(SerializerStats) SendMetadataNetworkStats(NetworkStats) SendParralelismStats(stats ParralelismStats) RegisterSeriesNetwork(func(NetworkStats)) NotificationRelease RegisterMetadataNetwork(func(NetworkStats)) NotificationRelease RegisterSerializer(func(SerializerStats)) NotificationRelease RegisterParralelism(func(ParralelismStats)) NotificationRelease }
StatsHub allows types to register to receive stats and to also send stats to fanout to receivers.
type SyncMailbox ¶
type SyncMailbox[T, R any] struct { // contains filtered or unexported fields }
SyncMailbox is used to synchronously send data, and wait for it to process before returning.
func NewSyncMailbox ¶
func NewSyncMailbox[T, R any](opt ...chann.Opt) *SyncMailbox[T, R]
func (*SyncMailbox[T, R]) ReceiveC ¶
func (sm *SyncMailbox[T, R]) ReceiveC() <-chan *Callback[T, R]
type Unmarshaller ¶
type Unmarshaller interface { // Unmarshal is called to create a list of datums. // Metadata will be passed via the map. // The buffer passed in is SAFE for reuse/unsafe strings. Unmarshal(map[string]string, []byte) (items []Datum, err error) }
Unmarshaller allows reading of a given FileFormat.