Fleunt-bit/Loki label_Filters not available in grafana loki datasource

Hello there, Team.

We recently began utilising grafana/loki:5.15.0, which is installed using helm. As a log forwarder, we’re using fluent-bit:0.37.1 (helm).

We attempted to add the loki datasource to Grafana and were able to view logs. However, we are unable to use the namespace label to filter deployments/containers.

I see that not all label_filters are available in grafana for filtering the loki datasource.

I can add a json parser, as shown below, to access the extra fields, but I require all fields to be available under “label_filters” so that I can design custom dashboards.

{app_kubernetes_io_name="test_app"} |= `` | json

Could you please let me know if there is any configuration on the Loki side that I have to configure? An existing example would be quite beneficial.

  1. You most likely do not want to make all fields into labels. See best practice here: Label best practices | Grafana Loki documentation. In general things that are random and without a fixed range of values aren’t great for labels.

  2. You can still create dashboards on fields that aren’t labels, that’s what filter such as json and pattern are for.

Thanks for the response @tonyswumac.

I am able to achieve it in Fluent-bit, using labelmap.json in fluent bit configuration.

{
  "kubernetes": {
    "container_name": "k8s_container_name",
    "container_hash": "k8s_container_hash",
    "host": "k8s_node",
    "labels": {
      "app.kubernetes.io/name": "k8s_app_name"
    },
    "namespace_name": "k8s_namespace_name",
    "pod_name": "k8s_pod_name"
  },
  "stream": "stream",
  "TENANT": "tenant"
}
[OUTPUT]
  name loki
  host loki-gateway:3100
  match *
  port 80
  auto_kubernetes_labels off
  label_map_path /fluent-bit/etc/conf/labelmap.json