From b2399f1599f0bbe47ff5ba72b7b043dce95cca65 Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Wed, 7 Jul 2021 14:36:19 -0400 Subject: [PATCH 1/2] operator: create CRDs for logging --- .../apis/monitoring/v1alpha1/group.go | 4 + .../apis/monitoring/v1alpha1/types.go | 240 +------ .../apis/monitoring/v1alpha1/types_logs.go | 529 ++++++++++++++ .../apis/monitoring/v1alpha1/types_metrics.go | 244 +++++++ .../v1alpha1/zz_generated.deepcopy.go | 676 ++++++++++++++++++ ...monitoring.grafana.com_grafana-agents.yaml | 450 +++++++++++- ...monitoring.grafana.com_logs-instances.yaml | 318 ++++++++ .../crds/monitoring.grafana.com_pod-logs.yaml | 346 +++++++++ 8 files changed, 2543 insertions(+), 264 deletions(-) create mode 100644 pkg/operator/apis/monitoring/v1alpha1/types_logs.go create mode 100644 pkg/operator/apis/monitoring/v1alpha1/types_metrics.go create mode 100644 production/operator/crds/monitoring.grafana.com_logs-instances.yaml create mode 100644 production/operator/crds/monitoring.grafana.com_pod-logs.yaml diff --git a/pkg/operator/apis/monitoring/v1alpha1/group.go b/pkg/operator/apis/monitoring/v1alpha1/group.go index 4e107e2ce7e8..9394899f58a8 100644 --- a/pkg/operator/apis/monitoring/v1alpha1/group.go +++ b/pkg/operator/apis/monitoring/v1alpha1/group.go @@ -26,5 +26,9 @@ func init() { &GrafanaAgentList{}, &PrometheusInstance{}, &PrometheusInstanceList{}, + &LogsInstance{}, + &LogsInstanceList{}, + &PodLogs{}, + &PodLogsList{}, ) } diff --git a/pkg/operator/apis/monitoring/v1alpha1/types.go b/pkg/operator/apis/monitoring/v1alpha1/types.go index cb9540dec859..a36ec951722c 100644 --- a/pkg/operator/apis/monitoring/v1alpha1/types.go +++ b/pkg/operator/apis/monitoring/v1alpha1/types.go @@ -124,241 +124,7 @@ type GrafanaAgentSpec struct { // Prometheus controls the Prometheus subsystem of the Agent and settings // unique to Prometheus-specific pods that are deployed. Prometheus PrometheusSubsystemSpec `json:"prometheus,omitempty"` -} - -// RemoteWriteSpec defines the remote_write configuration for Prometheus. -type RemoteWriteSpec struct { - // Name of the remote_write queue. Must be unique if specified. The name is - // used in metrics and logging in order to differentiate queues. - Name string `json:"name,omitempty"` - // URL of the endpoint to send samples to. - URL string `json:"url"` - // RemoteTimeout is the timeout for requests to the remote_write endpoint. - RemoteTimeout string `json:"remoteTimeout,omitempty"` - // Headers is a set of custom HTTP headers to be sent along with each - // remote_write request. Be aware that any headers set by Grafana Agent - // itself can't be overwritten. - Headers map[string]string `json:"headers,omitempty"` - // WriteRelabelConfigs holds relabel_configs to relabel samples before they are - // sent to the remote_write endpoint. - WriteRelabelConfigs []prom_v1.RelabelConfig `json:"writeRelabelConfigs,omitempty"` - // BasicAuth for the URL. - BasicAuth *prom_v1.BasicAuth `json:"basicAuth,omitempty"` - // BearerToken used for remote_write. - BearerToken string `json:"bearerToken,omitempty"` - // BearerTokenFile used to read bearer token. - BearerTokenFile string `json:"bearerTokenFile,omitempty"` - // SigV4 configures SigV4-based authentication to the remote_write endpoint. - // Will be used if SigV4 is defined, even with an empty object. - SigV4 *SigV4Config `json:"sigv4,omitempty"` - // TLSConfig to use for remote_write. - TLSConfig *prom_v1.TLSConfig `json:"tlsConfig,omitempty"` - // ProxyURL to proxy requests through. Optional. - ProxyURL string `json:"proxyUrl,omitempty"` - // QueueConfig allows tuning of the remote_write queue parameters. - QueueConfig *QueueConfig `json:"queueConfig,omitempty"` - // MetadataConfig configures the sending of series metadata to remote storage. - MetadataConfig *MetadataConfig `json:"metadataConfig,omitempty"` -} - -// SigV4Config specifies configuration to perform SigV4 authentication. -type SigV4Config struct { - // Region of the AWS endpoint. If blank, the region from the default - // credentials chain is used. - Region string `json:"region,omitempty"` - // AccessKey holds the secret of the AWS API access key to use for signing. - // If not provided, The environment variable AWS_ACCESS_KEY_ID is used. - AccessKey *v1.SecretKeySelector `json:"accessKey,omitempty"` - // SecretKey of the AWS API to use for signing. If blank, the environment - // variable AWS_SECRET_ACCESS_KEY is used. - SecretKey *v1.SecretKeySelector `json:"secretKey,omitempty"` - // Profile is the named AWS profile to use for authentication. - Profile string `json:"profile,omitempty"` - // RoleARN is the AWS Role ARN to use for authentication, as an alternative - // for using the AWS API keys. - RoleARN string `json:"roleARN,omitempty"` -} - -// QueueConfig allows the tuning of remote_write queue_config parameters. -type QueueConfig struct { - // Capacity is the number of samples to buffer per shard before we start dropping them. - Capacity int `json:"capacity,omitempty"` - // MinShards is the minimum number of shards, i.e. amount of concurrency. - MinShards int `json:"minShards,omitempty"` - // MaxShards is the maximum number of shards, i.e. amount of concurrency. - MaxShards int `json:"maxShards,omitempty"` - // MaxSamplesPerSend is the maximum number of samples per send. - MaxSamplesPerSend int `json:"maxSamplesPerSend,omitempty"` - // BatchSendDeadline is the maximum time a sample will wait in buffer. - BatchSendDeadline string `json:"batchSendDeadline,omitempty"` - // MaxRetries is the maximum number of times to retry a batch on recoverable errors. - MaxRetries int `json:"maxRetries,omitempty"` - // MinBackoff is the initial retry delay. Gets doubled for every retry. - MinBackoff string `json:"minBackoff,omitempty"` - // MaxBackoff is the maximum retry delay. - MaxBackoff string `json:"maxBackoff,omitempty"` - // RetryOnRateLimit retries requests when encountering rate limits. - RetryOnRateLimit bool `json:"retryOnRateLimit,omitempty"` -} - -// MetadataConfig configures the sending of series metadata to remote storage. -type MetadataConfig struct { - // Send enables metric metadata to be sent to remote storage. - Send bool `json:"send,omitempty"` - // SendInterval controls how frequently metric metadata is sent to remote storage. - SendInterval string `json:"sendInterval,omitempty"` -} - -// PrometheusSubsystemSpec defines global settings to apply across the -// Prometheus subsystem. -type PrometheusSubsystemSpec struct { - // RemoteWrite controls default remote_write settings for all instances. If - // an instance does not provide its own remoteWrite settings, these will be - // used instead. - RemoteWrite []RemoteWriteSpec `json:"remoteWrite,omitempty"` - // Replicas of each shard to deploy for metrics pods. Number of replicas - // multiplied by the number of shards is the total number of pods created. - Replicas *int32 `json:"replicas,omitempty"` - // Shards to distribute targets onto. Number of replicas multiplied by the - // number of shards is the total number of pods created. Note that scaling - // down shards will not reshard data onto remaining instances, it must be - // manually moved. Increasing shards will not reshard data either but it will - // continue to be available from the same instances. Sharding is performed on - // the content of the __address__ target meta-label. - Shards *int32 `json:"shards,omitempty"` - // ReplicaExternalLabelName is the name of the Prometheus external label used - // to denote replica name. Defaults to __replica__. External label will _not_ - // be added when value is set to the empty string. - ReplicaExternalLabelName *string `json:"replicaExternalLabelName,omitempty"` - // PrometheusExternalLabelName is the name of the external label used to - // denote Grafana Agent cluster. Defaults to "cluster." External label will - // _not_ be added when value is set to the empty string. - PrometheusExternalLabelName *string `json:"prometheusExternalLabelName,omitempty"` - // ScrapeInterval is the time between consecutive scrapes. - ScrapeInterval string `json:"scrapeInterval,omitempty"` - // ScrapeTimeout is the time to wait for a target to respond before marking a - // scrape as failed. - ScrapeTimeout string `json:"scrapeTimeout,omitempty"` - // ExternalLabels are labels to add to any time series when sending data over - // remote_write. - ExternalLabels map[string]string `json:"externalLabels,omitempty"` - // ArbitraryFSAccessThroughSMs configures whether configuration based on a - // ServiceMonitor can access arbitrary files on the file system of the - // Grafana Agent container e.g. bearer token files. - ArbitraryFSAccessThroughSMs prom_v1.ArbitraryFSAccessThroughSMsConfig `json:"arbitraryFSAccessThroughSMs,omitempty"` - // OverrideHonorLabels, if true, overrides all configured honor_labels read - // from ServiceMonitor or PodMonitor to false. - OverrideHonorLabels bool `json:"overrideHonorLabels,omitempty"` - // OverrideHonorTimestamps allows to globally enforce honoring timestamps in all scrape configs. - OverrideHonorTimestamps bool `json:"overrideHonorTimestamps,omitempty"` - // IgnoreNamespaceSelectors, if true, will ignore NamespaceSelector settings - // from the PodMonitor and ServiceMonitor configs, and they will only - // discover endpoints within their current namespace. - IgnoreNamespaceSelectors bool `json:"ignoreNamespaceSelectors,omitempty"` - // EnforcedNamepsaceLabel enforces adding a namespace label of origin for - // each metric that is user-created. The label value will always be the - // namespace of the object that is being created. - EnforcedNamepsaceLabel string `json:"enforcedNamespaceLabel,omitempty"` - // EnforcedSampleLimit defines global limit on the number of scraped samples - // that will be accepted. This overrides any SampleLimit set per - // ServiceMonitor and/or PodMonitor. It is meant to be used by admins to - // enforce the SampleLimit to keep the overall number of samples and series - // under the desired limit. Note that if a SampleLimit from a ServiceMonitor - // or PodMonitor is lower, that value will be used instead. - EnforcedSampleLimit *uint64 `json:"enforcedSampleLimit,omitempty"` - // EnforcedTargetLimit defines a global limit on the number of scraped - // targets. This overrides any TargetLimit set per ServiceMonitor and/or - // PodMonitor. It is meant to be used by admins to enforce the TargetLimit to - // keep the overall number of targets under the desired limit. Note that if a - // TargetLimit from a ServiceMonitor or PodMonitor is higher, that value will - // be used instead. - EnforcedTargetLimit *uint64 `json:"enforcedTargetLimit,omitempty"` - - // InstanceSelector determines which PrometheusInstances should be selected - // for running. Each instance runs its own set of Prometheus components, - // including service discovery, scraping, and remote_write. - InstanceSelector *metav1.LabelSelector `json:"instanceSelector,omitempty"` - // InstanceNamespaceSelector are the set of labels to determine which - // namespaces to watch for PrometheusInstances. If not provided, only checks own namespace. - InstanceNamespaceSelector *metav1.LabelSelector `json:"instanceNamespaceSelector,omitempty"` -} - -// +kubebuilder:object:root=true -// +kubebuilder:resource:path="prometheus-instances" -// +kubebuilder:resource:singular="prometheus-instance" -// +kubebuilder:resource:categories="agent-operator" - -// PrometheusInstance controls an individual Prometheus instance within a -// Grafana Agent deployment. -type PrometheusInstance struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - // Spec holds the specification of the desired behavior for the Prometheus - // instance. - Spec PrometheusInstanceSpec `json:"spec,omitempty"` -} - -// PrometheusInstanceSpec controls how an individual instance will be used to discover PodMonitors. -type PrometheusInstanceSpec struct { - // WALTruncateFrequency specifies how frequently the WAL truncation process - // should run. Higher values causes the WAL to increase and for old series to - // stay in the WAL for longer, but reduces the chances of data loss when - // remote_write is failing for longer than the given frequency. - WALTruncateFrequency string `json:"walTruncateFrequency,omitempty"` - // MinWALTime is the minimum amount of time series and samples may exist in - // the WAL before being considered for deletion. - MinWALTime string `json:"minWALTime,omitempty"` - // MaxWALTime is the maximum amount of time series and asmples may exist in - // the WAL before being forcibly deleted. - MaxWALTime string `json:"maxWALTime,omitempty"` - // RemoteFlushDeadline is the deadline for flushing data when an instance - // shuts down. - RemoteFlushDeadline string `json:"remoteFlushDeadline,omitempty"` - // WriteStaleOnShutdown writes staleness markers on shutdown for all series. - WriteStaleOnShutdown *bool `json:"writeStaleOnShutdown,omitempty"` - // ServiceMonitorSelector determines which ServiceMonitors should be selected - // for target discovery. - ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"` - // ServiceMonitorNamespaceSelector are the set of labels to determine which - // namespaces to watch for ServiceMonitor discovery. If nil, only checks own - // namespace. - ServiceMonitorNamespaceSelector *metav1.LabelSelector `json:"serviceMonitorNamespaceSelector,omitempty"` - // PodMonitorSelector determines which PodMonitors should be selected for target - // discovery. Experimental. - PodMonitorSelector *metav1.LabelSelector `json:"podMonitorSelector,omitempty"` - // PodMonitorNamespaceSelector are the set of labels to determine which - // namespaces to watch for PodMonitor discovery. If nil, only checks own - // namespace. - PodMonitorNamespaceSelector *metav1.LabelSelector `json:"podMonitorNamespaceSelector,omitempty"` - // ProbeSelector determines which Probes should be selected for target - // discovery. - ProbeSelector *metav1.LabelSelector `json:"probeSelector,omitempty"` - // ProbeNamespaceSelector are the set of labels to determine which namespaces - // to watch for Probe discovery. If nil, only checks own namespace. - ProbeNamespaceSelector *metav1.LabelSelector `json:"probeNamespaceSelector,omitempty"` - // RemoteWrite controls remote_write settings for this instance. - RemoteWrite []RemoteWriteSpec `json:"remoteWrite,omitempty"` - // AdditionalScrapeConfigs allows specifying a key of a Secret containing - // additional Grafana Agent Prometheus scrape configurations. SCrape - // configurations specified are appended to the configurations generated by - // the Grafana Agent Operator. Job configurations specified must have the - // form as specified in the official Prometheus documentation: - // https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config. - // As scrape configs are appended, the user is responsible to make sure it is - // valid. Note that using this feature may expose the possibility to break - // upgrades of Grafana Agent. It is advised to review both Grafana Agent and - // Prometheus release notes to ensure that no incompatible scrape configs are - // going to break Grafana Agent after the upgrade. - AdditionalScrapeConfigs *v1.SecretKeySelector `json:"additionalScrapeConfigs,omitempty"` -} - -// +kubebuilder:object:root=true - -// PrometheusInstanceList is a list of PrometheusInsatnce. -type PrometheusInstanceList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - // Items is the list of PrometheusInstance. - Items []*PrometheusInstance `json:"items"` + // Logs controls the logging subsystem of the Agent and settings unique to + // logging-specific pods that are deployed. + Logs LogsSubsystemSpec `json:"logs,omitempty"` } diff --git a/pkg/operator/apis/monitoring/v1alpha1/types_logs.go b/pkg/operator/apis/monitoring/v1alpha1/types_logs.go new file mode 100644 index 000000000000..9b28271b9aec --- /dev/null +++ b/pkg/operator/apis/monitoring/v1alpha1/types_logs.go @@ -0,0 +1,529 @@ +package v1alpha1 + +import ( + prom_v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// LogsSubsystemSpec defines global settings to apply across the logging +// subsystem. +type LogsSubsystemSpec struct { + // Global set of clients to use when a discovered LogsInstance does not + // have any clients defined. + Clients []LogsClientSpec `json:"clients,omitempty"` + // LogsExternalLabelName is the name of the external label used to + // denote Grafana Agent cluster. Defaults to "cluster." External label will + // _not_ be added when value is set to the empty string. + LogsExternalLabelName *string `json:"prometheusExternalLabelName,omitempty"` + // InstanceSelector determines which LogInstances should be selected + // for running. Each instance runs its own set of Prometheus components, + // including service discovery, scraping, and remote_write. + InstanceSelector *metav1.LabelSelector `json:"instanceSelector,omitempty"` + // InstanceNamespaceSelector are the set of labels to determine which + // namespaces to watch for LogInstances. If not provided, only checks own + // namespace. + InstanceNamespaceSelector *metav1.LabelSelector `json:"instanceNamespaceSelector,omitempty"` +} + +// LogsClientSpec defines the client integration for logs, indicating which +// Loki server to send logs to. +type LogsClientSpec struct { + // URL is the URL where Loki is listening. Must be a full HTTP URL, including + // protocol. + // Example: https://logs-prod-us-central1.grafana.net/loki/api/v1/push. + URL string `json:"url"` + // Tenant ID used by default to push logs to Loki. If ommited assumes remote + // Loki is running in single-tenant mode or an authentication layer is used + // to inject an X-Scope-OrgID header. + TenantID string `json:"tenantId"` + // Maximum amount of time to wait before sending a batch, even if that batch + // isn't full. + BatchWait string `json:"batchWait"` + // Maximum batch size (in bytes) of logs to accumulate before sending the + // batch to Loki. + BatchSize int `json:"batchSize"` + // BasicAuth for the Loki server. + BasicAuth *prom_v1.BasicAuth `json:"basicAuth,omitempty"` + // BearerToken used for remote_write. + BearerToken string `json:"bearerToken,omitempty"` + // BearerTokenFile used to read bearer token. + BearerTokenFile string `json:"bearerTokenFile,omitempty"` + // ProxyURL to proxy requests through. Optional. + ProxyURL string `json:"proxyUrl,omitempty"` + // TLSConfig to use for the client. Only used when the protocol of the URL + // is https. + TLSConfig *prom_v1.TLSConfig `json:"tlsConfig,omitempty"` + // Configures how to retry requests to Loki when a request fails. + // Defaults to a minPeriod of 500ms, maxPeriod of 5m, and maxRetries of 10. + BackoffConfig *LogsBackoffConfigSpec `json:"backoffConfig,omitempty"` + // ExternalLabels are labels to add to any time series when sending data to + // Loki. + ExternalLabels map[string]string `json:"externalLabels,omitempty"` + // Maximum time to wait for a server to respond to a request. + Timeout string `json:"timeout,omitempty"` +} + +// LogsBackoffConfigSpec configures timing for retrying failed requests. +type LogsBackoffConfigSpec struct { + // Initial backoff time between retries. Time between retries is + // increased exponentially. + MinPeriod string `json:"minPeriod,omitempty"` + // Maximum backoff time between retries. + MaxPeriod string `json:"maxPeriod,omitempty"` + // Maximum number of retries to perform before giving up a request. + MaxRetries int `json:"maxRetries,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:resource:path="logs-instances" +// +kubebuilder:resource:singular="logs-instance" +// +kubebuilder:resource:categories="agent-operator" + +// LogsInstance controls an individual logs instance within a Grafana Agent +// deployment. +type LogsInstance struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the specification of the desired behavior for the logs + // instance. + Spec LogsInstanceSpec `json:"spec,omitempty"` +} + +// LogsInstanceSpec controls how an individual instance will be used to +// discover LogMonitors. +type LogsInstanceSpec struct { + // Clients controls where logs are written to for this instance. + Clients []LogsClientSpec `json:"clients,omitempty"` + + // Determines which PodLogs should be selected for including in this + // instance. + PodLogsSelector *metav1.LabelSelector `json:"podLogsSelector,omitempty"` + // Set of labels to determine which namespaces should be watched + // for PodLogs. If not provided, checks only namespace of the + // instance. + PodLogsNamespaceSelector *metav1.LabelSelector `json:"podLogsNamespaceSelector,omitempty"` + + // AdditionalScrapeConfigs allows specifying a key of a Secret containing + // additional Grafana Agent logging scrape configurations. Scrape + // configurations specified are appended to the configurations generated by + // the Grafana Agent Operator. + // + // Job configurations specified must have the form as specified in the + // official Promtail documentation: + // + // https://grafana.com/docs/loki/latest/clients/promtail/configuration/#scrape_configs + // + // As scrape configs are appended, the user is responsible to make sure it is + // valid. Note that using this feature may expose the possibility to break + // upgrades of Grafana Agent. It is advised to review both Grafana Agent and + // Promtail release notes to ensure that no incompatible scrape configs are + // going to break Grafana Agent after the upgrade. + AdditionalScrapeConfigs *v1.SecretKeySelector `json:"additionalScrapeConfigs,omitempty"` + + // Configures how tailed targets will be watched. + TargetConfig LogsTargetConfigSpec `json:"targetConfig,omitempty"` +} + +// LogsTargetConfigSpec configures how tailed targets are watched. +type LogsTargetConfigSpec struct { + // Period to resync directories being watched and files being tailed to discover + // new ones or stop watching removed ones. + SyncPeriod string `json:"syncPeriod,omitempty"` +} + +// +kubebuilder:object:root=true + +// LogsInstanceList is a list of LogsInstance. +type LogsInstanceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + // Items is the list of LogsInstance. + Items []*LogsInstance `json:"items"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:resource:path="pod-logs" +// +kubebuilder:resource:singular="pod-logs" +// +kubebuilder:resource:categories="agent-operator" + +// PodLogs defines how to collect logs for a pod. +type PodLogs struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the specification of the desired behavior for the PodLogs. + Spec PodLogsSpec `json:"spec,omitempty"` +} + +// PodLogsSpec defines how to collect logs for a pod. +type PodLogsSpec struct { + // The label to use to retrieve the job name from. + JobLabel string `json:"jobLabel,omitempty"` + // PodTargetLabels transfers labels on the Kubernetes Pod onto the target. + PodTargetLabels []string `json:"podTargetLabels,omitempty"` + // Selector to select Pod objects. + Selector metav1.LabelSelector `json:"selector"` + // Selector to select which namespaces the Pod objects are discovered from. + NamespaceSelector prom_v1.NamespaceSelector `json:"namespaceSelector,omitempty"` + + // Pipeline stages for this pod. Pipeline stages allow for transforming and + // filtering log lines. + PipelineStages []*PipelineStageSpec `json:"pipelineStages,omitempty"` + + // RelabelConfigs to apply to logs before delivering. + // Grafana Agent Operator automatically adds relabelings for a few standard + // Kubernetes fields and replaces original scrape job name with + // __tmp_logs_job_name. + // + // More info: https://grafana.com/docs/loki/latest/clients/promtail/configuration/#relabel_configs + RelabelConfigs []*prom_v1.RelabelConfig `json:"relabelings,omitempty"` +} + +// +kubebuilder:object:root=true + +// PodLogsList is a list of PodLogs. +type PodLogsList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + // Items is the list of PodLogs. + Items []*PodLogs `json:"items"` +} + +// PipelineStageSpec defines an individual pipeline stage. Each stage type is +// mutually exclusive and no more than one may be set per stage. +// +// More information on pipelines can be found in the Promtail documentation: +// https://grafana.com/docs/loki/latest/clients/promtail/pipelines/ +type PipelineStageSpec struct { + // CRI is a parsing stage that reads log lines using the standard + // CRI logging format. Supply cri: {} to enable. + CRI *CRIStageSpec `json:"cri,omitempty"` + // Docker is a parsing stage that reads log lines using the standard + // Docker logging format. Supply docker: {} to enable. + Docker *DockerStageSpec `json:"docker,omitempty"` + // Drop is a filtering stage that lets you drop certain logs. + Drop *DropStageSpec `json:"drop,omitempty"` + // JSON is a parsing stage that reads the log line as JSON and accepts + // JMESPath expressions to extract data. + // + // Information on JMESPath: http://jmespath.org/ + JSON *JSONStageSpec `json:"json,omitempty"` + // LabelAllow is an action stage that only allows the provided labels to be + // included in the label set that is sent to Loki with the log entry. + LabelAllow []string `json:"labelAllow,omitempty"` + // LabelDrop is an action stage that drops labels from the label set that + // is sent to Loki with the log entry. + LabelDrop []string `json:"labelDrop,omitempty"` + // Labels is an action stage that takes data from the extracted map and + // modifies the label set that is sent to Loki with the log entry. + // + // The key is REQUIRED and represents the name for the label that will + // be created. Value is optional and will be the name from extracted data + // to use for the value of the label. If the value is not provided, it + // defaults to match the key. + Labels map[string]string `json:"labels,omitempty"` + // Match is a filtering stage that conditionally applies a set of stages + // or drop entries when a log entry matches a configurable LogQL stream + // selector and filter expressions. + Match *MatchStageSpec `json:"match,omitempty"` + // Metrics is an action stage that allows for defining and updating metrics + // based on data from the extracted map. Created metrics are not pushed to + // Loki or Prometheus and are instead exposed via the /metrics endpoint of + // the Grafana Agent pod. The Grafana Agent Operator should be configured + // with a MetricsInstance that discovers the logging DaemonSet to collect + // metrics created by this stage. + Metrics map[string]*MetricsStageSpec `json:"metrics,omitempty"` + // Multiline stage merges multiple lines into a multiline block before + // passing it on to the next stage in the pipeline. + Multiline *MultilineStageSpec `json:"multiline,omitempty"` + // Output stage is an action stage that takes data from the extracted map and + // changes the log line that will be sent to Loki. + Output *OutputStageSpec `json:"output,omitempty"` + // Pack is a transform stage that lets you embed extracted values and labels + // into the log line by packing the log line and labels inside of a JSON + // object. + Pack *PackStageSpec `json:"pack,omitempty"` + // Regex is a parsing stage that parses a log line using a regular + // expression. Named capture groups in the regex allows for adding data into + // the extracted map. + Regex *RegexStageSpec `json:"regex,omitempty"` + // Replace is a parsing stage that parses a log line using a regular + // expression and replaces the log line. Named capture groups in the regex + // allows for adding data into the extracted map. + Replace *ReplaceStageSpec `json:"replace,omitempty"` + // Template is a transform stage that manipulates the values in the extracted + // map using Go's template syntax. + Template *TemplateStageSpec `json:"template,omitempty"` + // Tenant is an action stage that sets the tenant ID for the log entry picking it from a + // field in the extracted data map. If the field is missing, the default + // LogsClientSpec.tenantId will be used. + Tenant *TenantStageSpec `json:"tenant,omitempty"` + // Timestamp is an action stage that can change the timestamp of a log line + // before it is sent to Loki. If not present, the timestamp of a log line + // defaults to the time when the log line was read. + Timestamp *TimestampStageSpec `json:"timestamp,omitempty"` +} + +// CRIStageSpec is a parsing stage that reads log lines using the standard CRI +// logging format. It needs no defined fields. +type CRIStageSpec struct{} + +// DockerStageSpec is a parsing stage that reads log lines using the standard +// Docker logging format. It needs no defined fields. +type DockerStageSpec struct{} + +// DropStageSpec is a filtering stage that lets you drop certain logs. +type DropStageSpec struct { + // Name from the extract data to parse. If empty, uses the log message. + Source string `json:"source,omitempty"` + + // RE2 regular exprssion. + // + // If source is provided, the regex will attempt + // to match the source. + // + // If no source is provided, then the regex will attempt + // to attach the log line. + // + // If the provided regex matches the log line or a provided source, the + // line will be dropped. + Expression string `json:"expression,omitempty"` + + // Value can only be specified when source is specified. If the value + // provided is an exact match for the given source then the line will be + // dropped. + // + // Mutually exclusive with expression. + Value string `json:"value,omitempty"` + + // OlderThan will be parsed as a Go duration. If the log line's timestamp + // is older than the current time minus the provided duration it will be + // dropped. + OlderThan string `json:"olderThan,omitempty"` + + // LongerThan will drop a log line if it its content is longer than this + // value (in bytes). Can be expressed as an integer (8192) or a number with a + // suffix (8kb). + LongerThan string `json:"longerThan,omitempty"` + + // Every time a log line is dropped the metric logentry_dropped_lines_total + // will be incremented. A "reason" label is added, and can be customized by + // providing a custom value here. Defaults to "drop_stage." + DropCounterReason string `json:"dropCounterReason,omitempty"` +} + +// JSONStageSpec is a parsing stage that reads the log line as JSON and accepts +// JMESPath expressions to extract data. +type JSONStageSpec struct { + // Name from the extracted data to parse as JSON. If empty, uses entire log + // message. + Source string `json:"source,omitempty"` + + // Set of the key/value pairs of JMESPath expressions. The key will be the + // key in the extracted data while the expression will be the value, + // evaluated as a JMESPath from the source data. + // + // Literal JMESPath exprssions can be done by wrapping a key in double + // quotes, which then must be wrapped again in single quotes in YAML + // so they get passed to the JMESPath parser. + Expressions map[string]string `json:"expressions,omitempty"` +} + +// MatchStageSpec is a filtering stage that conditionally applies a set of +// stages or drop entries when a log entry matches a configurable LogQL stream +// selector and filter expressions. +type MatchStageSpec struct { + // LogQL stream selector and filter expressions. + Selector string `json:"selector,omitempty"` + + // Names the pipeline. When defined, creates an additional label + // in the pipeline_duration_seconds histogram, where the value is + // concatenated with job_name using an underscore. + PipelineName string `json:"pipelineName,omitempty"` + + // Determines what action is taken when the selector matches the log line. + // Can be keep or drop. Defualts to keep. When set to drop, entries will be + // dropped and no later metrics will be recorded. + // Stages must be empty when dropping metrics. + Action string `json:"action,omitempty"` + + // Every time a log line is dropped the metric logentry_dropped_lines_total + // will be incremented. A "reason" label is added, and can be customized by + // providing a custom value here. Defaults to "match_stage." + DropCounterReason string `json:"dropCounterReason,omitempty"` + + // Nested set of pipeline stages to execute when action: keep and the log + // line matches selector. + Stages []*PipelineStageSpec `json:"staged,omitempty"` +} + +// MetricsStageSpec is an action stage that allows for defining and updating +// metrics based on data from the extracted map. Created metrics are not pushed +// to Loki or Prometheus and are instead exposed via the /metrics endpoint of +// the Grafana Agent pod. The Grafana Agent Operator should be configured with +// a MetricsInstance that discovers the logging DaemonSet to collect metrics +// created by this stage. +type MetricsStageSpec struct { + // The metric type to create. Must be one of counter, gauge, histogram. + Type string `json:"type,omitempty"` + + // Sets the description for the created metric. + Description string `json:"description,omitempty"` + + // Sets the custom prefix name for the metric. Defaults to "promtail_custom_". + Prefix string `json:"prefix,omitempty"` + + // Key from the extracted data map to use for the metric. Defaults to the + // metrics name if not present. + Source string `json:"source,omitempty"` + + // Label values on metrics are dynamic which can cause exported metrics + // to go stale. To prevent unbounded cardinality, any metrics not updated + // within MaxIdleDuration will be removed. + // + // Must be greater or equal to 1s. Defaults to 5m. + MaxIdleDuration string `json:"maxIdleDuration,omitempty"` + + // If true all log lines will be counted without attempting to match the + // source to the extracted map. Mutually exclusive with value. + // + // Only valid for type: counter. + MatchAll *bool `json:"matchAll,omitempty"` + + // If true all log line bytes will be counted. Can only be set with + // matchAll: true and action: add. + // + // Only valid for type: counter. + CountEntryBytes *bool `json:"countEntryBytes,omitempty"` + + // Filters down source data and only changes the metric if the targeted + // value exactly matches the provided string. If not present, all + // data will match. + Value string `json:"value,omitempty"` + + // The action to take against the metric. + // + // Must be either "inc" or "add" for type: counter or type: histogram. + // When type: gauge, must be one of "set", "inc", "dec", "add", or "sub". + // + // "add", "set", or "sub" requires the extracted value to be convertible + // to a positive float. + Action string `json:"action,omitempty"` + + // Buckets to create. + // Only valid for type: histogram. + Buckets []int `json:"bucket,omitempty"` +} + +// MultilineStageSpec merges multiple lines into a multiline block before +// passing it on to the next stage in the pipeline. +type MultilineStageSpec struct { + // RE2 regular expression. Creates a new multiline block when matched. + // Required. + FirstLine string `json:"firstLine,omitempty"` + + // Maximum time to wait before passing on the multiline block to the next + // stage if no new lines are received. Defaults to 3s. + MaxWaitTime string `json:"maxWaitTime,omitempty"` + + // Maximum number of lines a block can have. A new block is started if + // the number of lines surpasses this value. Defaults to 128. + MaxLines int `json:"maxLines,omitempty"` +} + +// OutputStageSpec is an action stage that takes data from the extracted map +// and changes the log line that will be sent to Loki. +type OutputStageSpec struct { + // Name from extract data to use for the log entry. + Source string `json:"source,omitempty"` +} + +// PackStageSpec is a transform stage that lets you embed extracted values and +// labels into the log line by packing the log line and labels inside of a JSON +// object. +type PackStageSpec struct { + // Name from extracted data or line labels. + // Labels provided here are automatically removed from output labels. + Labels []string `json:"labels,omitempty"` + + // If the resulting log line should use any existing timestamp or use time.Now() + // when the line was created. Set to true when combining several log streams from + // different containers to avoid out of order errors. + IngestTimestamp bool `json:"ingestTimestamp,omitempty"` +} + +// RegexStageSpec is a parsing stage that parses a log line using a regular +// expression. Named capture groups in the regex allows for adding data into +// the extracted map. +type RegexStageSpec struct { + // Name from extracted data to parse. If empty, defaults to using the log + // message. + Source string `json:"source,omitempty"` + + // RE2 regular expression. Each capture group MUST be named. + Expression string `json:"expression,omitempty"` +} + +// ReplaceStageSpec is a parsing stage that parses a log line using a regular +// expression and replaces the log line. Named capture groups in the regex +// allows for adding data into the extracted map. +type ReplaceStageSpec struct { + // Name from extracted data to parse. If empty, defaults to using the log + // message. + Source string `json:"source,omitempty"` + + // RE2 regular expression. Each capture group MUST be named. + Expression string `json:"expression,omitempty"` + + // Value to replace the captured group with. + Replace string `json:"replace,omitempty"` +} + +// TemplateStageSpec is a transform stage that manipulates the values in the +// extracted map using Go's template syntax. +type TemplateStageSpec struct { + // Name from extracted data to parse. If empty, defaults to using the log + // message. + Source string `json:"source,omitempty"` + + // Go template string to use. In additional to normal template functions, + // ToLower, ToUpper, Replace, Trim, TrimLeft, TrimRight, TrimPrefix, and + // TrimSpace are also available. + Template string `json:"template,omitempty"` +} + +// TenantStageSpec is an action stage that sets the tenant ID for the log entry +// picking it from a field in the extracted data map. +type TenantStageSpec struct { + // Name from extracted data to use as the tenant ID. Mutually exclusive with + // value. + Source string `json:"source,omitempty"` + + // Value to use for the template ID. Useful when this stage is used within a + // conditional pipeline such as match. Mutually exclusive with source. + Value string `json:"value,omitempty"` +} + +// TimestampStageSpec is an action stage that can change the timestamp of a log +// line before it is sent to Loki. +type TimestampStageSpec struct { + // Name from extracted data to use as the timestamp. + Source string `json:"source,omitempty"` + + // Determines format of the time string. Can be one of: + // ANSIC, UnixDate, RubyDate, RFC822, RFC822Z, RFC850, RFC1123, RFC1123Z, + // RFC3339, RFC3339Nano, Unix, UnixMs, UnixUs, UnixNs. + Format string `json:"format,omitempty"` + + // Fallback formats to try if format fails. + FallbackFormats []string `json:"fallbackFormats,omitempty"` + + // IANA Timezone Database string. + Location string `json:"location,omitempty"` + + // Action to take when the timestamp can't be extracted or parsed. + // Can be skip or fudge. Defaults to fudge. + ActionOnFailure string `json:"actionOnFailure,omitempty"` +} diff --git a/pkg/operator/apis/monitoring/v1alpha1/types_metrics.go b/pkg/operator/apis/monitoring/v1alpha1/types_metrics.go new file mode 100644 index 000000000000..9fcc243c914d --- /dev/null +++ b/pkg/operator/apis/monitoring/v1alpha1/types_metrics.go @@ -0,0 +1,244 @@ +package v1alpha1 + +import ( + prom_v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// PrometheusSubsystemSpec defines global settings to apply across the +// Prometheus subsystem. +type PrometheusSubsystemSpec struct { + // RemoteWrite controls default remote_write settings for all instances. If + // an instance does not provide its own remoteWrite settings, these will be + // used instead. + RemoteWrite []RemoteWriteSpec `json:"remoteWrite,omitempty"` + // Replicas of each shard to deploy for metrics pods. Number of replicas + // multiplied by the number of shards is the total number of pods created. + Replicas *int32 `json:"replicas,omitempty"` + // Shards to distribute targets onto. Number of replicas multiplied by the + // number of shards is the total number of pods created. Note that scaling + // down shards will not reshard data onto remaining instances, it must be + // manually moved. Increasing shards will not reshard data either but it will + // continue to be available from the same instances. Sharding is performed on + // the content of the __address__ target meta-label. + Shards *int32 `json:"shards,omitempty"` + // ReplicaExternalLabelName is the name of the Prometheus external label used + // to denote replica name. Defaults to __replica__. External label will _not_ + // be added when value is set to the empty string. + ReplicaExternalLabelName *string `json:"replicaExternalLabelName,omitempty"` + // PrometheusExternalLabelName is the name of the external label used to + // denote Grafana Agent cluster. Defaults to "cluster." External label will + // _not_ be added when value is set to the empty string. + PrometheusExternalLabelName *string `json:"prometheusExternalLabelName,omitempty"` + // ScrapeInterval is the time between consecutive scrapes. + ScrapeInterval string `json:"scrapeInterval,omitempty"` + // ScrapeTimeout is the time to wait for a target to respond before marking a + // scrape as failed. + ScrapeTimeout string `json:"scrapeTimeout,omitempty"` + // ExternalLabels are labels to add to any time series when sending data over + // remote_write. + ExternalLabels map[string]string `json:"externalLabels,omitempty"` + // ArbitraryFSAccessThroughSMs configures whether configuration based on a + // ServiceMonitor can access arbitrary files on the file system of the + // Grafana Agent container e.g. bearer token files. + ArbitraryFSAccessThroughSMs prom_v1.ArbitraryFSAccessThroughSMsConfig `json:"arbitraryFSAccessThroughSMs,omitempty"` + // OverrideHonorLabels, if true, overrides all configured honor_labels read + // from ServiceMonitor or PodMonitor to false. + OverrideHonorLabels bool `json:"overrideHonorLabels,omitempty"` + // OverrideHonorTimestamps allows to globally enforce honoring timestamps in all scrape configs. + OverrideHonorTimestamps bool `json:"overrideHonorTimestamps,omitempty"` + // IgnoreNamespaceSelectors, if true, will ignore NamespaceSelector settings + // from the PodMonitor and ServiceMonitor configs, and they will only + // discover endpoints within their current namespace. + IgnoreNamespaceSelectors bool `json:"ignoreNamespaceSelectors,omitempty"` + // EnforcedNamepsaceLabel enforces adding a namespace label of origin for + // each metric that is user-created. The label value will always be the + // namespace of the object that is being created. + EnforcedNamepsaceLabel string `json:"enforcedNamespaceLabel,omitempty"` + // EnforcedSampleLimit defines global limit on the number of scraped samples + // that will be accepted. This overrides any SampleLimit set per + // ServiceMonitor and/or PodMonitor. It is meant to be used by admins to + // enforce the SampleLimit to keep the overall number of samples and series + // under the desired limit. Note that if a SampleLimit from a ServiceMonitor + // or PodMonitor is lower, that value will be used instead. + EnforcedSampleLimit *uint64 `json:"enforcedSampleLimit,omitempty"` + // EnforcedTargetLimit defines a global limit on the number of scraped + // targets. This overrides any TargetLimit set per ServiceMonitor and/or + // PodMonitor. It is meant to be used by admins to enforce the TargetLimit to + // keep the overall number of targets under the desired limit. Note that if a + // TargetLimit from a ServiceMonitor or PodMonitor is higher, that value will + // be used instead. + EnforcedTargetLimit *uint64 `json:"enforcedTargetLimit,omitempty"` + + // InstanceSelector determines which PrometheusInstances should be selected + // for running. Each instance runs its own set of Prometheus components, + // including service discovery, scraping, and remote_write. + InstanceSelector *metav1.LabelSelector `json:"instanceSelector,omitempty"` + // InstanceNamespaceSelector are the set of labels to determine which + // namespaces to watch for PrometheusInstances. If not provided, only checks own namespace. + InstanceNamespaceSelector *metav1.LabelSelector `json:"instanceNamespaceSelector,omitempty"` +} + +// RemoteWriteSpec defines the remote_write configuration for Prometheus. +type RemoteWriteSpec struct { + // Name of the remote_write queue. Must be unique if specified. The name is + // used in metrics and logging in order to differentiate queues. + Name string `json:"name,omitempty"` + // URL of the endpoint to send samples to. + URL string `json:"url"` + // RemoteTimeout is the timeout for requests to the remote_write endpoint. + RemoteTimeout string `json:"remoteTimeout,omitempty"` + // Headers is a set of custom HTTP headers to be sent along with each + // remote_write request. Be aware that any headers set by Grafana Agent + // itself can't be overwritten. + Headers map[string]string `json:"headers,omitempty"` + // WriteRelabelConfigs holds relabel_configs to relabel samples before they are + // sent to the remote_write endpoint. + WriteRelabelConfigs []prom_v1.RelabelConfig `json:"writeRelabelConfigs,omitempty"` + // BasicAuth for the URL. + BasicAuth *prom_v1.BasicAuth `json:"basicAuth,omitempty"` + // BearerToken used for remote_write. + BearerToken string `json:"bearerToken,omitempty"` + // BearerTokenFile used to read bearer token. + BearerTokenFile string `json:"bearerTokenFile,omitempty"` + // SigV4 configures SigV4-based authentication to the remote_write endpoint. + // Will be used if SigV4 is defined, even with an empty object. + SigV4 *SigV4Config `json:"sigv4,omitempty"` + // TLSConfig to use for remote_write. + TLSConfig *prom_v1.TLSConfig `json:"tlsConfig,omitempty"` + // ProxyURL to proxy requests through. Optional. + ProxyURL string `json:"proxyUrl,omitempty"` + // QueueConfig allows tuning of the remote_write queue parameters. + QueueConfig *QueueConfig `json:"queueConfig,omitempty"` + // MetadataConfig configures the sending of series metadata to remote storage. + MetadataConfig *MetadataConfig `json:"metadataConfig,omitempty"` +} + +// SigV4Config specifies configuration to perform SigV4 authentication. +type SigV4Config struct { + // Region of the AWS endpoint. If blank, the region from the default + // credentials chain is used. + Region string `json:"region,omitempty"` + // AccessKey holds the secret of the AWS API access key to use for signing. + // If not provided, The environment variable AWS_ACCESS_KEY_ID is used. + AccessKey *v1.SecretKeySelector `json:"accessKey,omitempty"` + // SecretKey of the AWS API to use for signing. If blank, the environment + // variable AWS_SECRET_ACCESS_KEY is used. + SecretKey *v1.SecretKeySelector `json:"secretKey,omitempty"` + // Profile is the named AWS profile to use for authentication. + Profile string `json:"profile,omitempty"` + // RoleARN is the AWS Role ARN to use for authentication, as an alternative + // for using the AWS API keys. + RoleARN string `json:"roleARN,omitempty"` +} + +// QueueConfig allows the tuning of remote_write queue_config parameters. +type QueueConfig struct { + // Capacity is the number of samples to buffer per shard before we start dropping them. + Capacity int `json:"capacity,omitempty"` + // MinShards is the minimum number of shards, i.e. amount of concurrency. + MinShards int `json:"minShards,omitempty"` + // MaxShards is the maximum number of shards, i.e. amount of concurrency. + MaxShards int `json:"maxShards,omitempty"` + // MaxSamplesPerSend is the maximum number of samples per send. + MaxSamplesPerSend int `json:"maxSamplesPerSend,omitempty"` + // BatchSendDeadline is the maximum time a sample will wait in buffer. + BatchSendDeadline string `json:"batchSendDeadline,omitempty"` + // MaxRetries is the maximum number of times to retry a batch on recoverable errors. + MaxRetries int `json:"maxRetries,omitempty"` + // MinBackoff is the initial retry delay. Gets doubled for every retry. + MinBackoff string `json:"minBackoff,omitempty"` + // MaxBackoff is the maximum retry delay. + MaxBackoff string `json:"maxBackoff,omitempty"` + // RetryOnRateLimit retries requests when encountering rate limits. + RetryOnRateLimit bool `json:"retryOnRateLimit,omitempty"` +} + +// MetadataConfig configures the sending of series metadata to remote storage. +type MetadataConfig struct { + // Send enables metric metadata to be sent to remote storage. + Send bool `json:"send,omitempty"` + // SendInterval controls how frequently metric metadata is sent to remote storage. + SendInterval string `json:"sendInterval,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:resource:path="prometheus-instances" +// +kubebuilder:resource:singular="prometheus-instance" +// +kubebuilder:resource:categories="agent-operator" + +// PrometheusInstance controls an individual Prometheus instance within a +// Grafana Agent deployment. +type PrometheusInstance struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the specification of the desired behavior for the Prometheus + // instance. + Spec PrometheusInstanceSpec `json:"spec,omitempty"` +} + +// PrometheusInstanceSpec controls how an individual instance will be used to discover PodMonitors. +type PrometheusInstanceSpec struct { + // WALTruncateFrequency specifies how frequently the WAL truncation process + // should run. Higher values causes the WAL to increase and for old series to + // stay in the WAL for longer, but reduces the chances of data loss when + // remote_write is failing for longer than the given frequency. + WALTruncateFrequency string `json:"walTruncateFrequency,omitempty"` + // MinWALTime is the minimum amount of time series and samples may exist in + // the WAL before being considered for deletion. + MinWALTime string `json:"minWALTime,omitempty"` + // MaxWALTime is the maximum amount of time series and asmples may exist in + // the WAL before being forcibly deleted. + MaxWALTime string `json:"maxWALTime,omitempty"` + // RemoteFlushDeadline is the deadline for flushing data when an instance + // shuts down. + RemoteFlushDeadline string `json:"remoteFlushDeadline,omitempty"` + // WriteStaleOnShutdown writes staleness markers on shutdown for all series. + WriteStaleOnShutdown *bool `json:"writeStaleOnShutdown,omitempty"` + // ServiceMonitorSelector determines which ServiceMonitors should be selected + // for target discovery. + ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"` + // ServiceMonitorNamespaceSelector are the set of labels to determine which + // namespaces to watch for ServiceMonitor discovery. If nil, only checks own + // namespace. + ServiceMonitorNamespaceSelector *metav1.LabelSelector `json:"serviceMonitorNamespaceSelector,omitempty"` + // PodMonitorSelector determines which PodMonitors should be selected for target + // discovery. Experimental. + PodMonitorSelector *metav1.LabelSelector `json:"podMonitorSelector,omitempty"` + // PodMonitorNamespaceSelector are the set of labels to determine which + // namespaces to watch for PodMonitor discovery. If nil, only checks own + // namespace. + PodMonitorNamespaceSelector *metav1.LabelSelector `json:"podMonitorNamespaceSelector,omitempty"` + // ProbeSelector determines which Probes should be selected for target + // discovery. + ProbeSelector *metav1.LabelSelector `json:"probeSelector,omitempty"` + // ProbeNamespaceSelector are the set of labels to determine which namespaces + // to watch for Probe discovery. If nil, only checks own namespace. + ProbeNamespaceSelector *metav1.LabelSelector `json:"probeNamespaceSelector,omitempty"` + // RemoteWrite controls remote_write settings for this instance. + RemoteWrite []RemoteWriteSpec `json:"remoteWrite,omitempty"` + // AdditionalScrapeConfigs allows specifying a key of a Secret containing + // additional Grafana Agent Prometheus scrape configurations. SCrape + // configurations specified are appended to the configurations generated by + // the Grafana Agent Operator. Job configurations specified must have the + // form as specified in the official Prometheus documentation: + // https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config. + // As scrape configs are appended, the user is responsible to make sure it is + // valid. Note that using this feature may expose the possibility to break + // upgrades of Grafana Agent. It is advised to review both Grafana Agent and + // Prometheus release notes to ensure that no incompatible scrape configs are + // going to break Grafana Agent after the upgrade. + AdditionalScrapeConfigs *v1.SecretKeySelector `json:"additionalScrapeConfigs,omitempty"` +} + +// +kubebuilder:object:root=true + +// PrometheusInstanceList is a list of PrometheusInsatnce. +type PrometheusInstanceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + // Items is the list of PrometheusInstance. + Items []*PrometheusInstance `json:"items"` +} diff --git a/pkg/operator/apis/monitoring/v1alpha1/zz_generated.deepcopy.go b/pkg/operator/apis/monitoring/v1alpha1/zz_generated.deepcopy.go index a9edbfceb2c2..e8779f7deac8 100644 --- a/pkg/operator/apis/monitoring/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/operator/apis/monitoring/v1alpha1/zz_generated.deepcopy.go @@ -11,6 +11,51 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CRIStageSpec) DeepCopyInto(out *CRIStageSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CRIStageSpec. +func (in *CRIStageSpec) DeepCopy() *CRIStageSpec { + if in == nil { + return nil + } + out := new(CRIStageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DockerStageSpec) DeepCopyInto(out *DockerStageSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DockerStageSpec. +func (in *DockerStageSpec) DeepCopy() *DockerStageSpec { + if in == nil { + return nil + } + out := new(DockerStageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DropStageSpec) DeepCopyInto(out *DropStageSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DropStageSpec. +func (in *DropStageSpec) DeepCopy() *DropStageSpec { + if in == nil { + return nil + } + out := new(DropStageSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GrafanaAgent) DeepCopyInto(out *GrafanaAgent) { *out = *in @@ -172,6 +217,7 @@ func (in *GrafanaAgentSpec) DeepCopyInto(out *GrafanaAgentSpec) { } } in.Prometheus.DeepCopyInto(&out.Prometheus) + in.Logs.DeepCopyInto(&out.Logs) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GrafanaAgentSpec. @@ -184,6 +230,258 @@ func (in *GrafanaAgentSpec) DeepCopy() *GrafanaAgentSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *JSONStageSpec) DeepCopyInto(out *JSONStageSpec) { + *out = *in + if in.Expressions != nil { + in, out := &in.Expressions, &out.Expressions + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JSONStageSpec. +func (in *JSONStageSpec) DeepCopy() *JSONStageSpec { + if in == nil { + return nil + } + out := new(JSONStageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LogsBackoffConfigSpec) DeepCopyInto(out *LogsBackoffConfigSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LogsBackoffConfigSpec. +func (in *LogsBackoffConfigSpec) DeepCopy() *LogsBackoffConfigSpec { + if in == nil { + return nil + } + out := new(LogsBackoffConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LogsClientSpec) DeepCopyInto(out *LogsClientSpec) { + *out = *in + if in.BasicAuth != nil { + in, out := &in.BasicAuth, &out.BasicAuth + *out = new(v1.BasicAuth) + (*in).DeepCopyInto(*out) + } + if in.TLSConfig != nil { + in, out := &in.TLSConfig, &out.TLSConfig + *out = new(v1.TLSConfig) + (*in).DeepCopyInto(*out) + } + if in.BackoffConfig != nil { + in, out := &in.BackoffConfig, &out.BackoffConfig + *out = new(LogsBackoffConfigSpec) + **out = **in + } + if in.ExternalLabels != nil { + in, out := &in.ExternalLabels, &out.ExternalLabels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LogsClientSpec. +func (in *LogsClientSpec) DeepCopy() *LogsClientSpec { + if in == nil { + return nil + } + out := new(LogsClientSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LogsInstance) DeepCopyInto(out *LogsInstance) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LogsInstance. +func (in *LogsInstance) DeepCopy() *LogsInstance { + if in == nil { + return nil + } + out := new(LogsInstance) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *LogsInstance) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LogsInstanceList) DeepCopyInto(out *LogsInstanceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]*LogsInstance, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(LogsInstance) + (*in).DeepCopyInto(*out) + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LogsInstanceList. +func (in *LogsInstanceList) DeepCopy() *LogsInstanceList { + if in == nil { + return nil + } + out := new(LogsInstanceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *LogsInstanceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LogsInstanceSpec) DeepCopyInto(out *LogsInstanceSpec) { + *out = *in + if in.Clients != nil { + in, out := &in.Clients, &out.Clients + *out = make([]LogsClientSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.PodLogsSelector != nil { + in, out := &in.PodLogsSelector, &out.PodLogsSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.PodLogsNamespaceSelector != nil { + in, out := &in.PodLogsNamespaceSelector, &out.PodLogsNamespaceSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.AdditionalScrapeConfigs != nil { + in, out := &in.AdditionalScrapeConfigs, &out.AdditionalScrapeConfigs + *out = new(corev1.SecretKeySelector) + (*in).DeepCopyInto(*out) + } + out.TargetConfig = in.TargetConfig +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LogsInstanceSpec. +func (in *LogsInstanceSpec) DeepCopy() *LogsInstanceSpec { + if in == nil { + return nil + } + out := new(LogsInstanceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LogsSubsystemSpec) DeepCopyInto(out *LogsSubsystemSpec) { + *out = *in + if in.Clients != nil { + in, out := &in.Clients, &out.Clients + *out = make([]LogsClientSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.LogsExternalLabelName != nil { + in, out := &in.LogsExternalLabelName, &out.LogsExternalLabelName + *out = new(string) + **out = **in + } + if in.InstanceSelector != nil { + in, out := &in.InstanceSelector, &out.InstanceSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.InstanceNamespaceSelector != nil { + in, out := &in.InstanceNamespaceSelector, &out.InstanceNamespaceSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LogsSubsystemSpec. +func (in *LogsSubsystemSpec) DeepCopy() *LogsSubsystemSpec { + if in == nil { + return nil + } + out := new(LogsSubsystemSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LogsTargetConfigSpec) DeepCopyInto(out *LogsTargetConfigSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LogsTargetConfigSpec. +func (in *LogsTargetConfigSpec) DeepCopy() *LogsTargetConfigSpec { + if in == nil { + return nil + } + out := new(LogsTargetConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MatchStageSpec) DeepCopyInto(out *MatchStageSpec) { + *out = *in + if in.Stages != nil { + in, out := &in.Stages, &out.Stages + *out = make([]*PipelineStageSpec, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(PipelineStageSpec) + (*in).DeepCopyInto(*out) + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchStageSpec. +func (in *MatchStageSpec) DeepCopy() *MatchStageSpec { + if in == nil { + return nil + } + out := new(MatchStageSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MetadataConfig) DeepCopyInto(out *MetadataConfig) { *out = *in @@ -199,6 +497,304 @@ func (in *MetadataConfig) DeepCopy() *MetadataConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricsStageSpec) DeepCopyInto(out *MetricsStageSpec) { + *out = *in + if in.MatchAll != nil { + in, out := &in.MatchAll, &out.MatchAll + *out = new(bool) + **out = **in + } + if in.CountEntryBytes != nil { + in, out := &in.CountEntryBytes, &out.CountEntryBytes + *out = new(bool) + **out = **in + } + if in.Buckets != nil { + in, out := &in.Buckets, &out.Buckets + *out = make([]int, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricsStageSpec. +func (in *MetricsStageSpec) DeepCopy() *MetricsStageSpec { + if in == nil { + return nil + } + out := new(MetricsStageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MultilineStageSpec) DeepCopyInto(out *MultilineStageSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MultilineStageSpec. +func (in *MultilineStageSpec) DeepCopy() *MultilineStageSpec { + if in == nil { + return nil + } + out := new(MultilineStageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OutputStageSpec) DeepCopyInto(out *OutputStageSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OutputStageSpec. +func (in *OutputStageSpec) DeepCopy() *OutputStageSpec { + if in == nil { + return nil + } + out := new(OutputStageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PackStageSpec) DeepCopyInto(out *PackStageSpec) { + *out = *in + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackStageSpec. +func (in *PackStageSpec) DeepCopy() *PackStageSpec { + if in == nil { + return nil + } + out := new(PackStageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PipelineStageSpec) DeepCopyInto(out *PipelineStageSpec) { + *out = *in + if in.CRI != nil { + in, out := &in.CRI, &out.CRI + *out = new(CRIStageSpec) + **out = **in + } + if in.Docker != nil { + in, out := &in.Docker, &out.Docker + *out = new(DockerStageSpec) + **out = **in + } + if in.Drop != nil { + in, out := &in.Drop, &out.Drop + *out = new(DropStageSpec) + **out = **in + } + if in.JSON != nil { + in, out := &in.JSON, &out.JSON + *out = new(JSONStageSpec) + (*in).DeepCopyInto(*out) + } + if in.LabelAllow != nil { + in, out := &in.LabelAllow, &out.LabelAllow + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.LabelDrop != nil { + in, out := &in.LabelDrop, &out.LabelDrop + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Match != nil { + in, out := &in.Match, &out.Match + *out = new(MatchStageSpec) + (*in).DeepCopyInto(*out) + } + if in.Metrics != nil { + in, out := &in.Metrics, &out.Metrics + *out = make(map[string]*MetricsStageSpec, len(*in)) + for key, val := range *in { + var outVal *MetricsStageSpec + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = new(MetricsStageSpec) + (*in).DeepCopyInto(*out) + } + (*out)[key] = outVal + } + } + if in.Multiline != nil { + in, out := &in.Multiline, &out.Multiline + *out = new(MultilineStageSpec) + **out = **in + } + if in.Output != nil { + in, out := &in.Output, &out.Output + *out = new(OutputStageSpec) + **out = **in + } + if in.Pack != nil { + in, out := &in.Pack, &out.Pack + *out = new(PackStageSpec) + (*in).DeepCopyInto(*out) + } + if in.Regex != nil { + in, out := &in.Regex, &out.Regex + *out = new(RegexStageSpec) + **out = **in + } + if in.Replace != nil { + in, out := &in.Replace, &out.Replace + *out = new(ReplaceStageSpec) + **out = **in + } + if in.Template != nil { + in, out := &in.Template, &out.Template + *out = new(TemplateStageSpec) + **out = **in + } + if in.Tenant != nil { + in, out := &in.Tenant, &out.Tenant + *out = new(TenantStageSpec) + **out = **in + } + if in.Timestamp != nil { + in, out := &in.Timestamp, &out.Timestamp + *out = new(TimestampStageSpec) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineStageSpec. +func (in *PipelineStageSpec) DeepCopy() *PipelineStageSpec { + if in == nil { + return nil + } + out := new(PipelineStageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodLogs) DeepCopyInto(out *PodLogs) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodLogs. +func (in *PodLogs) DeepCopy() *PodLogs { + if in == nil { + return nil + } + out := new(PodLogs) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodLogs) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodLogsList) DeepCopyInto(out *PodLogsList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]*PodLogs, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(PodLogs) + (*in).DeepCopyInto(*out) + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodLogsList. +func (in *PodLogsList) DeepCopy() *PodLogsList { + if in == nil { + return nil + } + out := new(PodLogsList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodLogsList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodLogsSpec) DeepCopyInto(out *PodLogsSpec) { + *out = *in + if in.PodTargetLabels != nil { + in, out := &in.PodTargetLabels, &out.PodTargetLabels + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.Selector.DeepCopyInto(&out.Selector) + in.NamespaceSelector.DeepCopyInto(&out.NamespaceSelector) + if in.PipelineStages != nil { + in, out := &in.PipelineStages, &out.PipelineStages + *out = make([]*PipelineStageSpec, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(PipelineStageSpec) + (*in).DeepCopyInto(*out) + } + } + } + if in.RelabelConfigs != nil { + in, out := &in.RelabelConfigs, &out.RelabelConfigs + *out = make([]*v1.RelabelConfig, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(v1.RelabelConfig) + (*in).DeepCopyInto(*out) + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodLogsSpec. +func (in *PodLogsSpec) DeepCopy() *PodLogsSpec { + if in == nil { + return nil + } + out := new(PodLogsSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PrometheusInstance) DeepCopyInto(out *PrometheusInstance) { *out = *in @@ -408,6 +1004,21 @@ func (in *QueueConfig) DeepCopy() *QueueConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RegexStageSpec) DeepCopyInto(out *RegexStageSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegexStageSpec. +func (in *RegexStageSpec) DeepCopy() *RegexStageSpec { + if in == nil { + return nil + } + out := new(RegexStageSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteWriteSpec) DeepCopyInto(out *RemoteWriteSpec) { *out = *in @@ -462,6 +1073,21 @@ func (in *RemoteWriteSpec) DeepCopy() *RemoteWriteSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ReplaceStageSpec) DeepCopyInto(out *ReplaceStageSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReplaceStageSpec. +func (in *ReplaceStageSpec) DeepCopy() *ReplaceStageSpec { + if in == nil { + return nil + } + out := new(ReplaceStageSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SigV4Config) DeepCopyInto(out *SigV4Config) { *out = *in @@ -486,3 +1112,53 @@ func (in *SigV4Config) DeepCopy() *SigV4Config { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TemplateStageSpec) DeepCopyInto(out *TemplateStageSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TemplateStageSpec. +func (in *TemplateStageSpec) DeepCopy() *TemplateStageSpec { + if in == nil { + return nil + } + out := new(TemplateStageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TenantStageSpec) DeepCopyInto(out *TenantStageSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TenantStageSpec. +func (in *TenantStageSpec) DeepCopy() *TenantStageSpec { + if in == nil { + return nil + } + out := new(TenantStageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TimestampStageSpec) DeepCopyInto(out *TimestampStageSpec) { + *out = *in + if in.FallbackFormats != nil { + in, out := &in.FallbackFormats, &out.FallbackFormats + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TimestampStageSpec. +func (in *TimestampStageSpec) DeepCopy() *TimestampStageSpec { + if in == nil { + return nil + } + out := new(TimestampStageSpec) + in.DeepCopyInto(out) + return out +} diff --git a/production/operator/crds/monitoring.grafana.com_grafana-agents.yaml b/production/operator/crds/monitoring.grafana.com_grafana-agents.yaml index e25d8c6e72a3..bc4503a8ed5a 100644 --- a/production/operator/crds/monitoring.grafana.com_grafana-agents.yaml +++ b/production/operator/crds/monitoring.grafana.com_grafana-agents.yaml @@ -197,8 +197,38 @@ spec: description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. type: object type: object + namespaceSelector: + description: A label query over the set of namespaces that the term applies to. The term is applied to the union of the namespaces selected by this field and the ones listed in the namespaces field. null selector and null or empty namespaces list means "this pod's namespace". An empty selector ({}) matches all namespaces. This field is alpha-level and is only honored when PodAffinityNamespaceSelector feature is enabled. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object namespaces: - description: namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means "this pod's namespace" + description: namespaces specifies a static list of namespace names that the term applies to. The term is applied to the union of the namespaces listed in this field and the ones selected by namespaceSelector. null or empty namespaces list and null namespaceSelector means "this pod's namespace" items: type: string type: array @@ -252,8 +282,38 @@ spec: description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. type: object type: object + namespaceSelector: + description: A label query over the set of namespaces that the term applies to. The term is applied to the union of the namespaces selected by this field and the ones listed in the namespaces field. null selector and null or empty namespaces list means "this pod's namespace". An empty selector ({}) matches all namespaces. This field is alpha-level and is only honored when PodAffinityNamespaceSelector feature is enabled. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object namespaces: - description: namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means "this pod's namespace" + description: namespaces specifies a static list of namespace names that the term applies to. The term is applied to the union of the namespaces listed in this field and the ones selected by namespaceSelector. null or empty namespaces list and null namespaceSelector means "this pod's namespace" items: type: string type: array @@ -306,8 +366,38 @@ spec: description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. type: object type: object + namespaceSelector: + description: A label query over the set of namespaces that the term applies to. The term is applied to the union of the namespaces selected by this field and the ones listed in the namespaces field. null selector and null or empty namespaces list means "this pod's namespace". An empty selector ({}) matches all namespaces. This field is alpha-level and is only honored when PodAffinityNamespaceSelector feature is enabled. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object namespaces: - description: namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means "this pod's namespace" + description: namespaces specifies a static list of namespace names that the term applies to. The term is applied to the union of the namespaces listed in this field and the ones selected by namespaceSelector. null or empty namespaces list and null namespaceSelector means "this pod's namespace" items: type: string type: array @@ -361,8 +451,38 @@ spec: description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. type: object type: object + namespaceSelector: + description: A label query over the set of namespaces that the term applies to. The term is applied to the union of the namespaces selected by this field and the ones listed in the namespaces field. null selector and null or empty namespaces list means "this pod's namespace". An empty selector ({}) matches all namespaces. This field is alpha-level and is only honored when PodAffinityNamespaceSelector feature is enabled. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object namespaces: - description: namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means "this pod's namespace" + description: namespaces specifies a static list of namespace names that the term applies to. The term is applied to the union of the namespaces listed in this field and the ones selected by namespaceSelector. null or empty namespaces list and null namespaceSelector means "this pod's namespace" items: type: string type: array @@ -876,6 +996,10 @@ spec: required: - port type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is an alpha field and requires enabling ProbeTerminationGracePeriod feature gate. + format: int64 + type: integer timeoutSeconds: description: 'Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' format: int32 @@ -995,13 +1119,17 @@ spec: required: - port type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is an alpha field and requires enabling ProbeTerminationGracePeriod feature gate. + format: int64 + type: integer timeoutSeconds: description: 'Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' format: int32 type: integer type: object resources: - description: 'Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: 'Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' properties: limits: additionalProperties: @@ -1010,7 +1138,7 @@ spec: - type: string pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object requests: additionalProperties: @@ -1019,7 +1147,7 @@ spec: - type: string pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object securityContext: @@ -1107,7 +1235,7 @@ spec: type: object type: object startupProbe: - description: 'StartupProbe indicates that the Pod has successfully initialized. If specified, no other probes are executed until this completes successfully. If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. This can be used to provide different probe parameters at the beginning of a Pod''s lifecycle, when it might take a long time to load data or warm a cache, than during steady-state operation. This cannot be updated. This is a beta feature enabled by the StartupProbe feature flag. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + description: 'StartupProbe indicates that the Pod has successfully initialized. If specified, no other probes are executed until this completes successfully. If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. This can be used to provide different probe parameters at the beginning of a Pod''s lifecycle, when it might take a long time to load data or warm a cache, than during steady-state operation. This cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' properties: exec: description: One and only one of the following should be specified. Exec specifies the action to take. @@ -1186,6 +1314,10 @@ spec: required: - port type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is an alpha field and requires enabling ProbeTerminationGracePeriod feature gate. + format: int64 + type: integer timeoutSeconds: description: 'Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' format: int32 @@ -1615,6 +1747,10 @@ spec: required: - port type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is an alpha field and requires enabling ProbeTerminationGracePeriod feature gate. + format: int64 + type: integer timeoutSeconds: description: 'Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' format: int32 @@ -1734,13 +1870,17 @@ spec: required: - port type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is an alpha field and requires enabling ProbeTerminationGracePeriod feature gate. + format: int64 + type: integer timeoutSeconds: description: 'Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' format: int32 type: integer type: object resources: - description: 'Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: 'Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' properties: limits: additionalProperties: @@ -1749,7 +1889,7 @@ spec: - type: string pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object requests: additionalProperties: @@ -1758,7 +1898,7 @@ spec: - type: string pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object securityContext: @@ -1846,7 +1986,7 @@ spec: type: object type: object startupProbe: - description: 'StartupProbe indicates that the Pod has successfully initialized. If specified, no other probes are executed until this completes successfully. If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. This can be used to provide different probe parameters at the beginning of a Pod''s lifecycle, when it might take a long time to load data or warm a cache, than during steady-state operation. This cannot be updated. This is a beta feature enabled by the StartupProbe feature flag. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + description: 'StartupProbe indicates that the Pod has successfully initialized. If specified, no other probes are executed until this completes successfully. If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. This can be used to provide different probe parameters at the beginning of a Pod''s lifecycle, when it might take a long time to load data or warm a cache, than during steady-state operation. This cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' properties: exec: description: One and only one of the following should be specified. Exec specifies the action to take. @@ -1925,6 +2065,10 @@ spec: required: - port type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is an alpha field and requires enabling ProbeTerminationGracePeriod feature gate. + format: int64 + type: integer timeoutSeconds: description: 'Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' format: int32 @@ -2002,6 +2146,263 @@ spec: logLevel: description: LogLevel controls the log level of the generated pods. Defaults to "info" if not set. type: string + logs: + description: Logs controls the logging subsystem of the Agent and settings unique to logging-specific pods that are deployed. + properties: + clients: + description: Global set of clients to use when a discovered LogsInstance does not have any clients defined. + items: + description: LogsClientSpec defines the client integration for logs, indicating which Loki server to send logs to. + properties: + backoffConfig: + description: Configures how to retry requests to Loki when a request fails. Defaults to a minPeriod of 500ms, maxPeriod of 5m, and maxRetries of 10. + properties: + maxPeriod: + description: Maximum backoff time between retries. + type: string + maxRetries: + description: Maximum number of retries to perform before giving up a request. + type: integer + minPeriod: + description: Initial backoff time between retries. Time between retries is increased exponentially. + type: string + type: object + basicAuth: + description: BasicAuth for the Loki server. + properties: + password: + description: The secret in the service monitor namespace that contains the password for authentication. + properties: + key: + description: The key of the secret to select from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must be defined + type: boolean + required: + - key + type: object + username: + description: The secret in the service monitor namespace that contains the username for authentication. + properties: + key: + description: The key of the secret to select from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must be defined + type: boolean + required: + - key + type: object + type: object + batchSize: + description: Maximum batch size (in bytes) of logs to accumulate before sending the batch to Loki. + type: integer + batchWait: + description: Maximum amount of time to wait before sending a batch, even if that batch isn't full. + type: string + bearerToken: + description: BearerToken used for remote_write. + type: string + bearerTokenFile: + description: BearerTokenFile used to read bearer token. + type: string + externalLabels: + additionalProperties: + type: string + description: ExternalLabels are labels to add to any time series when sending data to Loki. + type: object + proxyUrl: + description: ProxyURL to proxy requests through. Optional. + type: string + tenantId: + description: Tenant ID used by default to push logs to Loki. If ommited assumes remote Loki is running in single-tenant mode or an authentication layer is used to inject an X-Scope-OrgID header. + type: string + timeout: + description: Maximum time to wait for a server to respond to a request. + type: string + tlsConfig: + description: TLSConfig to use for the client. Only used when the protocol of the URL is https. + properties: + ca: + description: Struct containing the CA cert to use for the targets. + properties: + configMap: + description: ConfigMap containing data to use for the targets. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap or its key must be defined + type: boolean + required: + - key + type: object + secret: + description: Secret containing data to use for the targets. + properties: + key: + description: The key of the secret to select from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must be defined + type: boolean + required: + - key + type: object + type: object + caFile: + description: Path to the CA cert in the Prometheus container to use for the targets. + type: string + cert: + description: Struct containing the client cert file for the targets. + properties: + configMap: + description: ConfigMap containing data to use for the targets. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap or its key must be defined + type: boolean + required: + - key + type: object + secret: + description: Secret containing data to use for the targets. + properties: + key: + description: The key of the secret to select from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must be defined + type: boolean + required: + - key + type: object + type: object + certFile: + description: Path to the client cert file in the Prometheus container for the targets. + type: string + insecureSkipVerify: + description: Disable target certificate validation. + type: boolean + keyFile: + description: Path to the client key file in the Prometheus container for the targets. + type: string + keySecret: + description: Secret containing the client key file for the targets. + properties: + key: + description: The key of the secret to select from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must be defined + type: boolean + required: + - key + type: object + serverName: + description: Used to verify the hostname for the targets. + type: string + type: object + url: + description: 'URL is the URL where Loki is listening. Must be a full HTTP URL, including protocol. Example: https://logs-prod-us-central1.grafana.net/loki/api/v1/push.' + type: string + required: + - batchSize + - batchWait + - tenantId + - url + type: object + type: array + instanceNamespaceSelector: + description: InstanceNamespaceSelector are the set of labels to determine which namespaces to watch for LogInstances. If not provided, only checks own namespace. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + instanceSelector: + description: InstanceSelector determines which LogInstances should be selected for running. Each instance runs its own set of Prometheus components, including service discovery, scraping, and remote_write. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + prometheusExternalLabelName: + description: LogsExternalLabelName is the name of the external label used to denote Grafana Agent cluster. Defaults to "cluster." External label will _not_ be added when value is set to the empty string. + type: string + type: object nodeSelector: additionalProperties: type: string @@ -2441,7 +2842,7 @@ spec: - type: string pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object requests: additionalProperties: @@ -2450,7 +2851,7 @@ spec: - type: string pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object secrets: @@ -2466,7 +2867,7 @@ spec: format: int64 type: integer fsGroupChangePolicy: - description: 'fsGroupChangePolicy defines behavior of changing ownership and permission of the volume before being exposed inside Pod. This field will only apply to volume types which support fsGroup based ownership(and permissions). It will have no effect on ephemeral volume types such as: secret, configmaps and emptydir. Valid values are "OnRootMismatch" and "Always". If not specified defaults to "Always".' + description: 'fsGroupChangePolicy defines behavior of changing ownership and permission of the volume before being exposed inside Pod. This field will only apply to volume types which support fsGroup based ownership(and permissions). It will have no effect on ephemeral volume types such as: secret, configmaps and emptydir. Valid values are "OnRootMismatch" and "Always". If not specified, "Always" is used.' type: string runAsGroup: description: The GID to run the entrypoint of the container process. Uses runtime default if unset. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container. @@ -2601,7 +3002,7 @@ spec: type: string type: array dataSource: - description: 'This field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot - Beta) * An existing PVC (PersistentVolumeClaim) * An existing custom resource/object that implements data population (Alpha) In order to use VolumeSnapshot object types, the appropriate feature gate must be enabled (VolumeSnapshotDataSource or AnyVolumeDataSource) If the provisioner or an external controller can support the specified data source, it will create a new volume based on the contents of the specified data source. If the specified data source is not supported, the volume will not be created and the failure will be reported as an event. In the future, we plan to support more data source types and the behavior of the provisioner may change.' + description: 'This field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) * An existing PVC (PersistentVolumeClaim) * An existing custom resource that implements data population (Alpha) In order to use custom resource types that implement data population, the AnyVolumeDataSource feature gate must be enabled. If the provisioner or an external controller can support the specified data source, it will create a new volume based on the contents of the specified data source.' properties: apiGroup: description: APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required. @@ -2626,7 +3027,7 @@ spec: - type: string pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object requests: additionalProperties: @@ -2635,7 +3036,7 @@ spec: - type: string pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object selector: @@ -3083,11 +3484,8 @@ spec: x-kubernetes-int-or-string: true type: object ephemeral: - description: "Ephemeral represents a volume that is handled by a cluster storage driver (Alpha feature). The volume's lifecycle is tied to the pod that defines it - it will be created before the pod starts, and deleted when the pod is removed. \n Use this if: a) the volume is only needed while the pod runs, b) features of normal volumes like restoring from snapshot or capacity tracking are needed, c) the storage driver is specified through a storage class, and d) the storage driver supports dynamic volume provisioning through a PersistentVolumeClaim (see EphemeralVolumeSource for more information on the connection between this volume type and PersistentVolumeClaim). \n Use PersistentVolumeClaim or one of the vendor-specific APIs for volumes that persist for longer than the lifecycle of an individual pod. \n Use CSI for light-weight local ephemeral volumes if the CSI driver is meant to be used that way - see the documentation of the driver for more information. \n A pod can use both types of ephemeral volumes and persistent volumes at the same time." + description: "Ephemeral represents a volume that is handled by a cluster storage driver. The volume's lifecycle is tied to the pod that defines it - it will be created before the pod starts, and deleted when the pod is removed. \n Use this if: a) the volume is only needed while the pod runs, b) features of normal volumes like restoring from snapshot or capacity tracking are needed, c) the storage driver is specified through a storage class, and d) the storage driver supports dynamic volume provisioning through a PersistentVolumeClaim (see EphemeralVolumeSource for more information on the connection between this volume type and PersistentVolumeClaim). \n Use PersistentVolumeClaim or one of the vendor-specific APIs for volumes that persist for longer than the lifecycle of an individual pod. \n Use CSI for light-weight local ephemeral volumes if the CSI driver is meant to be used that way - see the documentation of the driver for more information. \n A pod can use both types of ephemeral volumes and persistent volumes at the same time. \n This is a beta feature and only available when the GenericEphemeralVolume feature gate is enabled." properties: - readOnly: - description: Specifies a read-only configuration for the volume. Defaults to false (read/write). - type: boolean volumeClaimTemplate: description: "Will be used to create a stand-alone PVC to provision the volume. The pod in which this EphemeralVolumeSource is embedded will be the owner of the PVC, i.e. the PVC will be deleted together with the pod. The name of the PVC will be `-` where `` is the name from the `PodSpec.Volumes` array entry. Pod validation will reject the pod if the concatenated name is not valid for a PVC (for example, too long). \n An existing PVC with that name that is not owned by the pod will *not* be used for the pod to avoid using an unrelated volume by mistake. Starting the pod is then blocked until the unrelated PVC is removed. If such a pre-created PVC is meant to be used by the pod, the PVC has to updated with an owner reference to the pod once the pod exists. Normally this should not be necessary, but it may be useful when manually reconstructing a broken cluster. \n This field is read-only and no changes will be made by Kubernetes to the PVC after it has been created. \n Required, must not be nil." properties: @@ -3103,7 +3501,7 @@ spec: type: string type: array dataSource: - description: 'This field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot - Beta) * An existing PVC (PersistentVolumeClaim) * An existing custom resource/object that implements data population (Alpha) In order to use VolumeSnapshot object types, the appropriate feature gate must be enabled (VolumeSnapshotDataSource or AnyVolumeDataSource) If the provisioner or an external controller can support the specified data source, it will create a new volume based on the contents of the specified data source. If the specified data source is not supported, the volume will not be created and the failure will be reported as an event. In the future, we plan to support more data source types and the behavior of the provisioner may change.' + description: 'This field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) * An existing PVC (PersistentVolumeClaim) * An existing custom resource that implements data population (Alpha) In order to use custom resource types that implement data population, the AnyVolumeDataSource feature gate must be enabled. If the provisioner or an external controller can support the specified data source, it will create a new volume based on the contents of the specified data source.' properties: apiGroup: description: APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required. @@ -3128,7 +3526,7 @@ spec: - type: string pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object requests: additionalProperties: @@ -3137,7 +3535,7 @@ spec: - type: string pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object selector: @@ -3554,8 +3952,6 @@ spec: type: object type: object type: array - required: - - sources type: object quobyte: description: Quobyte represents a Quobyte mount on the host that shares a pod's lifetime diff --git a/production/operator/crds/monitoring.grafana.com_logs-instances.yaml b/production/operator/crds/monitoring.grafana.com_logs-instances.yaml new file mode 100644 index 000000000000..868fc1cd1396 --- /dev/null +++ b/production/operator/crds/monitoring.grafana.com_logs-instances.yaml @@ -0,0 +1,318 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.5.0 + creationTimestamp: null + name: logs-instances.monitoring.grafana.com +spec: + group: monitoring.grafana.com + names: + categories: + - agent-operator + kind: LogsInstance + listKind: LogsInstanceList + plural: logs-instances + singular: logs-instance + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: LogsInstance controls an individual logs instance within a Grafana Agent deployment. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: Spec holds the specification of the desired behavior for the logs instance. + properties: + additionalScrapeConfigs: + description: "AdditionalScrapeConfigs allows specifying a key of a Secret containing additional Grafana Agent logging scrape configurations. Scrape configurations specified are appended to the configurations generated by the Grafana Agent Operator. \n Job configurations specified must have the form as specified in the official Promtail documentation: \n https://grafana.com/docs/loki/latest/clients/promtail/configuration/#scrape_configs \n As scrape configs are appended, the user is responsible to make sure it is valid. Note that using this feature may expose the possibility to break upgrades of Grafana Agent. It is advised to review both Grafana Agent and Promtail release notes to ensure that no incompatible scrape configs are going to break Grafana Agent after the upgrade." + properties: + key: + description: The key of the secret to select from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must be defined + type: boolean + required: + - key + type: object + clients: + description: Clients controls where logs are written to for this instance. + items: + description: LogsClientSpec defines the client integration for logs, indicating which Loki server to send logs to. + properties: + backoffConfig: + description: Configures how to retry requests to Loki when a request fails. Defaults to a minPeriod of 500ms, maxPeriod of 5m, and maxRetries of 10. + properties: + maxPeriod: + description: Maximum backoff time between retries. + type: string + maxRetries: + description: Maximum number of retries to perform before giving up a request. + type: integer + minPeriod: + description: Initial backoff time between retries. Time between retries is increased exponentially. + type: string + type: object + basicAuth: + description: BasicAuth for the Loki server. + properties: + password: + description: The secret in the service monitor namespace that contains the password for authentication. + properties: + key: + description: The key of the secret to select from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must be defined + type: boolean + required: + - key + type: object + username: + description: The secret in the service monitor namespace that contains the username for authentication. + properties: + key: + description: The key of the secret to select from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must be defined + type: boolean + required: + - key + type: object + type: object + batchSize: + description: Maximum batch size (in bytes) of logs to accumulate before sending the batch to Loki. + type: integer + batchWait: + description: Maximum amount of time to wait before sending a batch, even if that batch isn't full. + type: string + bearerToken: + description: BearerToken used for remote_write. + type: string + bearerTokenFile: + description: BearerTokenFile used to read bearer token. + type: string + externalLabels: + additionalProperties: + type: string + description: ExternalLabels are labels to add to any time series when sending data to Loki. + type: object + proxyUrl: + description: ProxyURL to proxy requests through. Optional. + type: string + tenantId: + description: Tenant ID used by default to push logs to Loki. If ommited assumes remote Loki is running in single-tenant mode or an authentication layer is used to inject an X-Scope-OrgID header. + type: string + timeout: + description: Maximum time to wait for a server to respond to a request. + type: string + tlsConfig: + description: TLSConfig to use for the client. Only used when the protocol of the URL is https. + properties: + ca: + description: Struct containing the CA cert to use for the targets. + properties: + configMap: + description: ConfigMap containing data to use for the targets. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap or its key must be defined + type: boolean + required: + - key + type: object + secret: + description: Secret containing data to use for the targets. + properties: + key: + description: The key of the secret to select from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must be defined + type: boolean + required: + - key + type: object + type: object + caFile: + description: Path to the CA cert in the Prometheus container to use for the targets. + type: string + cert: + description: Struct containing the client cert file for the targets. + properties: + configMap: + description: ConfigMap containing data to use for the targets. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap or its key must be defined + type: boolean + required: + - key + type: object + secret: + description: Secret containing data to use for the targets. + properties: + key: + description: The key of the secret to select from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must be defined + type: boolean + required: + - key + type: object + type: object + certFile: + description: Path to the client cert file in the Prometheus container for the targets. + type: string + insecureSkipVerify: + description: Disable target certificate validation. + type: boolean + keyFile: + description: Path to the client key file in the Prometheus container for the targets. + type: string + keySecret: + description: Secret containing the client key file for the targets. + properties: + key: + description: The key of the secret to select from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must be defined + type: boolean + required: + - key + type: object + serverName: + description: Used to verify the hostname for the targets. + type: string + type: object + url: + description: 'URL is the URL where Loki is listening. Must be a full HTTP URL, including protocol. Example: https://logs-prod-us-central1.grafana.net/loki/api/v1/push.' + type: string + required: + - batchSize + - batchWait + - tenantId + - url + type: object + type: array + podLogsNamespaceSelector: + description: Set of labels to determine which namespaces should be watched for PodLogs. If not provided, checks only namespace of the instance. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + podLogsSelector: + description: Determines which PodLogs should be selected for including in this instance. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + targetConfig: + description: Configures how tailed targets will be watched. + properties: + syncPeriod: + description: Period to resync directories being watched and files being tailed to discover new ones or stop watching removed ones. + type: string + type: object + type: object + type: object + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/production/operator/crds/monitoring.grafana.com_pod-logs.yaml b/production/operator/crds/monitoring.grafana.com_pod-logs.yaml new file mode 100644 index 000000000000..d9df8f555c1a --- /dev/null +++ b/production/operator/crds/monitoring.grafana.com_pod-logs.yaml @@ -0,0 +1,346 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.5.0 + creationTimestamp: null + name: pod-logs.monitoring.grafana.com +spec: + group: monitoring.grafana.com + names: + categories: + - agent-operator + kind: PodLogs + listKind: PodLogsList + plural: pod-logs + singular: pod-logs + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: PodLogs defines how to collect logs for a pod. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: Spec holds the specification of the desired behavior for the PodLogs. + properties: + jobLabel: + description: The label to use to retrieve the job name from. + type: string + namespaceSelector: + description: Selector to select which namespaces the Pod objects are discovered from. + properties: + any: + description: Boolean describing whether all namespaces are selected in contrast to a list restricting them. + type: boolean + matchNames: + description: List of namespace names. + items: + type: string + type: array + type: object + pipelineStages: + description: Pipeline stages for this pod. Pipeline stages allow for transforming and filtering log lines. + items: + description: "PipelineStageSpec defines an individual pipeline stage. Each stage type is mutually exclusive and no more than one may be set per stage. \n More information on pipelines can be found in the Promtail documentation: https://grafana.com/docs/loki/latest/clients/promtail/pipelines/" + properties: + cri: + description: 'CRI is a parsing stage that reads log lines using the standard CRI logging format. Supply cri: {} to enable.' + type: object + docker: + description: 'Docker is a parsing stage that reads log lines using the standard Docker logging format. Supply docker: {} to enable.' + type: object + drop: + description: Drop is a filtering stage that lets you drop certain logs. + properties: + dropCounterReason: + description: Every time a log line is dropped the metric logentry_dropped_lines_total will be incremented. A "reason" label is added, and can be customized by providing a custom value here. Defaults to "drop_stage." + type: string + expression: + description: "RE2 regular exprssion. \n If source is provided, the regex will attempt to match the source. \n If no source is provided, then the regex will attempt to attach the log line. \n If the provided regex matches the log line or a provided source, the line will be dropped." + type: string + longerThan: + description: LongerThan will drop a log line if it its content is longer than this value (in bytes). Can be expressed as an integer (8192) or a number with a suffix (8kb). + type: string + olderThan: + description: OlderThan will be parsed as a Go duration. If the log line's timestamp is older than the current time minus the provided duration it will be dropped. + type: string + source: + description: Name from the extract data to parse. If empty, uses the log message. + type: string + value: + description: "Value can only be specified when source is specified. If the value provided is an exact match for the given source then the line will be dropped. \n Mutually exclusive with expression." + type: string + type: object + json: + description: "JSON is a parsing stage that reads the log line as JSON and accepts JMESPath expressions to extract data. \n Information on JMESPath: http://jmespath.org/" + properties: + expressions: + additionalProperties: + type: string + description: "Set of the key/value pairs of JMESPath expressions. The key will be the key in the extracted data while the expression will be the value, evaluated as a JMESPath from the source data. \n Literal JMESPath exprssions can be done by wrapping a key in double quotes, which then must be wrapped again in single quotes in YAML so they get passed to the JMESPath parser." + type: object + source: + description: Name from the extracted data to parse as JSON. If empty, uses entire log message. + type: string + type: object + labelAllow: + description: LabelAllow is an action stage that only allows the provided labels to be included in the label set that is sent to Loki with the log entry. + items: + type: string + type: array + labelDrop: + description: LabelDrop is an action stage that drops labels from the label set that is sent to Loki with the log entry. + items: + type: string + type: array + labels: + additionalProperties: + type: string + description: "Labels is an action stage that takes data from the extracted map and modifies the label set that is sent to Loki with the log entry. \n The key is REQUIRED and represents the name for the label that will be created. Value is optional and will be the name from extracted data to use for the value of the label. If the value is not provided, it defaults to match the key." + type: object + match: + description: Match is a filtering stage that conditionally applies a set of stages or drop entries when a log entry matches a configurable LogQL stream selector and filter expressions. + properties: + action: + description: Determines what action is taken when the selector matches the log line. Can be keep or drop. Defualts to keep. When set to drop, entries will be dropped and no later metrics will be recorded. Stages must be empty when dropping metrics. + type: string + dropCounterReason: + description: Every time a log line is dropped the metric logentry_dropped_lines_total will be incremented. A "reason" label is added, and can be customized by providing a custom value here. Defaults to "match_stage." + type: string + pipelineName: + description: Names the pipeline. When defined, creates an additional label in the pipeline_duration_seconds histogram, where the value is concatenated with job_name using an underscore. + type: string + selector: + description: LogQL stream selector and filter expressions. + type: string + staged: + description: 'Nested set of pipeline stages to execute when action: keep and the log line matches selector.' + items: {} + type: array + type: object + metrics: + additionalProperties: + description: MetricsStageSpec is an action stage that allows for defining and updating metrics based on data from the extracted map. Created metrics are not pushed to Loki or Prometheus and are instead exposed via the /metrics endpoint of the Grafana Agent pod. The Grafana Agent Operator should be configured with a MetricsInstance that discovers the logging DaemonSet to collect metrics created by this stage. + properties: + action: + description: "The action to take against the metric. \n Must be either \"inc\" or \"add\" for type: counter or type: histogram. When type: gauge, must be one of \"set\", \"inc\", \"dec\", \"add\", or \"sub\". \n \"add\", \"set\", or \"sub\" requires the extracted value to be convertible to a positive float." + type: string + bucket: + description: 'Buckets to create. Only valid for type: histogram.' + items: + type: integer + type: array + countEntryBytes: + description: "If true all log line bytes will be counted. Can only be set with matchAll: true and action: add. \n Only valid for type: counter." + type: boolean + description: + description: Sets the description for the created metric. + type: string + matchAll: + description: "If true all log lines will be counted without attempting to match the source to the extracted map. Mutually exclusive with value. \n Only valid for type: counter." + type: boolean + maxIdleDuration: + description: "Label values on metrics are dynamic which can cause exported metrics to go stale. To prevent unbounded cardinality, any metrics not updated within MaxIdleDuration will be removed. \n Must be greater or equal to 1s. Defaults to 5m." + type: string + prefix: + description: Sets the custom prefix name for the metric. Defaults to "promtail_custom_". + type: string + source: + description: Key from the extracted data map to use for the metric. Defaults to the metrics name if not present. + type: string + type: + description: The metric type to create. Must be one of counter, gauge, histogram. + type: string + value: + description: Filters down source data and only changes the metric if the targeted value exactly matches the provided string. If not present, all data will match. + type: string + type: object + description: Metrics is an action stage that allows for defining and updating metrics based on data from the extracted map. Created metrics are not pushed to Loki or Prometheus and are instead exposed via the /metrics endpoint of the Grafana Agent pod. The Grafana Agent Operator should be configured with a MetricsInstance that discovers the logging DaemonSet to collect metrics created by this stage. + type: object + multiline: + description: Multiline stage merges multiple lines into a multiline block before passing it on to the next stage in the pipeline. + properties: + firstLine: + description: RE2 regular expression. Creates a new multiline block when matched. Required. + type: string + maxLines: + description: Maximum number of lines a block can have. A new block is started if the number of lines surpasses this value. Defaults to 128. + type: integer + maxWaitTime: + description: Maximum time to wait before passing on the multiline block to the next stage if no new lines are received. Defaults to 3s. + type: string + type: object + output: + description: Output stage is an action stage that takes data from the extracted map and changes the log line that will be sent to Loki. + properties: + source: + description: Name from extract data to use for the log entry. + type: string + type: object + pack: + description: Pack is a transform stage that lets you embed extracted values and labels into the log line by packing the log line and labels inside of a JSON object. + properties: + ingestTimestamp: + description: If the resulting log line should use any existing timestamp or use time.Now() when the line was created. Set to true when combining several log streams from different containers to avoid out of order errors. + type: boolean + labels: + description: Name from extracted data or line labels. Labels provided here are automatically removed from output labels. + items: + type: string + type: array + type: object + regex: + description: Regex is a parsing stage that parses a log line using a regular expression. Named capture groups in the regex allows for adding data into the extracted map. + properties: + expression: + description: RE2 regular expression. Each capture group MUST be named. + type: string + source: + description: Name from extracted data to parse. If empty, defaults to using the log message. + type: string + type: object + replace: + description: Replace is a parsing stage that parses a log line using a regular expression and replaces the log line. Named capture groups in the regex allows for adding data into the extracted map. + properties: + expression: + description: RE2 regular expression. Each capture group MUST be named. + type: string + replace: + description: Value to replace the captured group with. + type: string + source: + description: Name from extracted data to parse. If empty, defaults to using the log message. + type: string + type: object + template: + description: Template is a transform stage that manipulates the values in the extracted map using Go's template syntax. + properties: + source: + description: Name from extracted data to parse. If empty, defaults to using the log message. + type: string + template: + description: Go template string to use. In additional to normal template functions, ToLower, ToUpper, Replace, Trim, TrimLeft, TrimRight, TrimPrefix, and TrimSpace are also available. + type: string + type: object + tenant: + description: Tenant is an action stage that sets the tenant ID for the log entry picking it from a field in the extracted data map. If the field is missing, the default LogsClientSpec.tenantId will be used. + properties: + source: + description: Name from extracted data to use as the tenant ID. Mutually exclusive with value. + type: string + value: + description: Value to use for the template ID. Useful when this stage is used within a conditional pipeline such as match. Mutually exclusive with source. + type: string + type: object + timestamp: + description: Timestamp is an action stage that can change the timestamp of a log line before it is sent to Loki. If not present, the timestamp of a log line defaults to the time when the log line was read. + properties: + actionOnFailure: + description: Action to take when the timestamp can't be extracted or parsed. Can be skip or fudge. Defaults to fudge. + type: string + fallbackFormats: + description: Fallback formats to try if format fails. + items: + type: string + type: array + format: + description: 'Determines format of the time string. Can be one of: ANSIC, UnixDate, RubyDate, RFC822, RFC822Z, RFC850, RFC1123, RFC1123Z, RFC3339, RFC3339Nano, Unix, UnixMs, UnixUs, UnixNs.' + type: string + location: + description: IANA Timezone Database string. + type: string + source: + description: Name from extracted data to use as the timestamp. + type: string + type: object + type: object + type: array + podTargetLabels: + description: PodTargetLabels transfers labels on the Kubernetes Pod onto the target. + items: + type: string + type: array + relabelings: + description: "RelabelConfigs to apply to logs before delivering. Grafana Agent Operator automatically adds relabelings for a few standard Kubernetes fields and replaces original scrape job name with __tmp_logs_job_name. \n More info: https://grafana.com/docs/loki/latest/clients/promtail/configuration/#relabel_configs" + items: + description: 'RelabelConfig allows dynamic rewriting of the label set, being applied to samples before ingestion. It defines ``-section of Prometheus configuration. More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs' + properties: + action: + description: Action to perform based on regex matching. Default is 'replace' + type: string + modulus: + description: Modulus to take of the hash of the source label values. + format: int64 + type: integer + regex: + description: Regular expression against which the extracted value is matched. Default is '(.*)' + type: string + replacement: + description: Replacement value against which a regex replace is performed if the regular expression matches. Regex capture groups are available. Default is '$1' + type: string + separator: + description: Separator placed between concatenated source label values. default is ';'. + type: string + sourceLabels: + description: The source labels select values from existing labels. Their content is concatenated using the configured separator and matched against the configured regular expression for the replace, keep, and drop actions. + items: + type: string + type: array + targetLabel: + description: Label to which the resulting value is written in a replace action. It is mandatory for replace actions. Regex capture groups are available. + type: string + type: object + type: array + selector: + description: Selector to select Pod objects. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + required: + - selector + type: object + type: object + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] From ca7a73f0d4c0fb50ba4729ce6d327b79b30fc87b Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Wed, 7 Jul 2021 15:37:11 -0400 Subject: [PATCH 2/2] fix lint nits --- pkg/operator/apis/monitoring/v1alpha1/types_logs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/operator/apis/monitoring/v1alpha1/types_logs.go b/pkg/operator/apis/monitoring/v1alpha1/types_logs.go index 9b28271b9aec..c20b2bd834de 100644 --- a/pkg/operator/apis/monitoring/v1alpha1/types_logs.go +++ b/pkg/operator/apis/monitoring/v1alpha1/types_logs.go @@ -33,7 +33,7 @@ type LogsClientSpec struct { // protocol. // Example: https://logs-prod-us-central1.grafana.net/loki/api/v1/push. URL string `json:"url"` - // Tenant ID used by default to push logs to Loki. If ommited assumes remote + // Tenant ID used by default to push logs to Loki. If omitted assumes remote // Loki is running in single-tenant mode or an authentication layer is used // to inject an X-Scope-OrgID header. TenantID string `json:"tenantId"` @@ -344,7 +344,7 @@ type MatchStageSpec struct { PipelineName string `json:"pipelineName,omitempty"` // Determines what action is taken when the selector matches the log line. - // Can be keep or drop. Defualts to keep. When set to drop, entries will be + // Can be keep or drop. Defaults to keep. When set to drop, entries will be // dropped and no later metrics will be recorded. // Stages must be empty when dropping metrics. Action string `json:"action,omitempty"`