github.com/observiq/carbon@v0.9.11-0.20200820160507-1b872e368a5e/docs/operators/k8s_metadata_decorator.md (about)

     1  ## `k8s_metadata_decorator` operator
     2  
     3  The `k8s_metadata_decorator` operator adds labels and annotations to the entry using data from the Kubernetes metadata API.
     4  
     5  ### Configuration Fields
     6  
     7  | Field             | Default                  | Description                                                                                                |
     8  | ---               | ---                      | ---                                                                                                        |
     9  | `id`              | `k8s_metadata_decorator` | A unique identifier for the operator                                                                       |
    10  | `output`          | Next in pipeline         | The connected operator(s) that will receive all outbound entries                                           |
    11  | `namespace_field` | `namespace`              | A [field](/docs/types/field.md) that contains the k8s namespace associated with the log entry              |
    12  | `pod_name_field`  | `pod_name`               | A [field](/docs/types/field.md) that contains the k8s pod name associated with the log entry               |
    13  | `cache_ttl`       | 10m                      | A [duration](/docs/types/duration.md) indicating the time it takes for a cached entry to expire            |
    14  | `timeout`         | 10s                      | A [duration](/docs/types/duration.md) indicating how long to wait for the API to respond before timing out |
    15  
    16  ### Example Configurations
    17  
    18  
    19  #### Add labels and annotations to a log entry
    20  
    21  Configuration:
    22  ```yaml
    23  - type: k8s_metadata_decorator
    24  ```
    25  
    26  <table>
    27  <tr><td> Input record </td> <td> Output record </td></tr>
    28  <tr>
    29  <td>
    30  
    31  ```json
    32  {
    33    "timestamp": "",
    34    "record": {
    35      "namespace": "my-namespace",
    36      "pod_name": "samplepod-6cdcf6bf9d-f4f9n"
    37    }
    38  }
    39  ```
    40  
    41  </td>
    42  <td>
    43  
    44  ```json
    45  {
    46    "timestamp": "",
    47    "labels": {
    48      "k8s_ns_annotation/addonmanager.kubernetes.io/mode": "Reconcile",
    49      "k8s_ns_annotation/control-plane": "true",
    50      "k8s_ns_annotation/kubernetes.io/cluster-service": "true",
    51      "k8s_ns_label/addonmanager.kubernetes.io/mode": "Reconcile",
    52      "k8s_ns_label/control-plane": "true",
    53      "k8s_ns_label/kubernetes.io/cluster-service": "true",
    54      "k8s_pod_annotation/k8s-app": "dashboard-metrics-scraper",
    55      "k8s_pod_annotation/pod-template-hash": "5f44bbb8b5",
    56      "k8s_pod_label/k8s-app": "dashboard-metrics-scraper",
    57      "k8s_pod_label/pod-template-hash": "5f44bbb8b5"
    58    },
    59    "record": {
    60      "namespace": "my-namespace",
    61      "pod_name": "samplepod-6cdcf6bf9d-f4f9n"
    62    }
    63  }
    64  ```
    65  
    66  </td>
    67  </tr>
    68  </table>