--- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.9.2 creationTimestamp: null name: podlogs.monitoring.grafana.com spec: group: monitoring.grafana.com names: categories: - agent-operator kind: PodLogs listKind: PodLogsList plural: podlogs singular: podlogs 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 to select from. items: type: string type: array type: object pipelineStages: description: Pipeline stages for this pod. Pipeline stages support 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 is 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 expression. \n If source is provided, the regex attempts to match the source. \n If no source is provided, then the regex attempts to attach the log line. \n If the provided regex matches the log line or a provided source, the line is 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 expressions can be used 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 limit: description: Limit is a rate-limiting stage that throttles logs based on several options. properties: burst: description: The cap in the quantity of burst lines that Promtail will push to Loki. type: integer drop: description: "When drop is true, log lines that exceed the current rate limit are discarded. When drop is false, log lines that exceed the current rate limit wait to enter the back pressure mode. \n Defaults to false." type: boolean rate: description: The rate limit in lines per second that Promtail will push to Loki. type: integer 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. Defaults to keep. When set to drop, entries are dropped and no later metrics are 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 is 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. Required. type: string stages: description: "Nested set of pipeline stages to execute when action is keep and the log line matches selector. \n An example value for stages may be: \n stages: | - json: {} - labelAllow: [foo, bar] \n Note that stages is a string because SIG API Machinery does not support recursive types, and so it cannot be validated for correctness. Be careful not to mistype anything." type: string required: - selector 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. Required. \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 buckets: description: 'Buckets to create. Bucket values must be convertible to float64s. Extremely large or small numbers are subject to some loss of precision. Only valid for type: histogram.' items: type: string type: array countEntryBytes: description: "If true all log line bytes are 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 are 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 are 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. Required. type: string value: description: Filters down source data and only changes the metric if the targeted value matches the provided string exactly. If not present, all data matches. type: string required: - action - type type: object description: Metrics is an action stage that supports 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 required: - firstLine 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. Required. type: string required: - source 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. Required. Labels provided here are automatically removed from output labels. items: type: string type: array required: - labels 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. Required. type: string source: description: Name from extracted data to parse. If empty, defaults to using the log message. type: string required: - expression 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. Required. 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 required: - expression 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. Required. If empty, defaults to using the log message. type: string template: description: Go template string to use. Required. In addition to normal template functions, ToLower, ToUpper, Replace, Trim, TrimLeft, TrimRight, TrimPrefix, and TrimSpace are also available. type: string required: - source - template 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: label: description: Name from labels whose value should be set as tenant ID. Mutually exclusive with source and value. type: string source: description: Name from extracted data to use as the tenant ID. Mutually exclusive with label and 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 label and 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. Required. 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. Required. type: string required: - format - source 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: default: replace description: Action to perform based on regex matching. Default is 'replace'. uppercase and lowercase actions require Prometheus >= 2.36. enum: - replace - Replace - keep - Keep - drop - Drop - hashmod - HashMod - labelmap - LabelMap - labeldrop - LabelDrop - labelkeep - LabelKeep - lowercase - Lowercase - uppercase - Uppercase - keepequal - KeepEqual - dropequal - DropEqual 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: description: LabelName is a valid Prometheus label name which may only contain ASCII letters, numbers, as well as underscores. pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$ 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. Required. 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 x-kubernetes-map-type: atomic required: - selector type: object type: object served: true storage: true