How to remove timestamp field?

Hello everyone!
Can you tell me how I can remove the timestamp field?
So that it is not displayed when viewed in Grafana.
Or if possible, it should look like UTC+3

These are my config.alloy settings

loki.write "grafana_loki" {
  endpoint {
    url = "http://192.168.1.58:3100/loki/api/v1/push"
  }
  external_labels = {
    host = "vmware",
  }
}

discovery.docker "containers" {
  host = "unix:///var/run/docker.sock"
}

discovery.relabel "containers" {
  targets = discovery.docker.containers.targets

  rule {
    action        = "replace"
    source_labels = ["__meta_docker_container_name"]
    target_label  = "container_name"
  }

  rule {
    action        = "replace"
    source_labels = ["__meta_docker_container_id"]
    target_label  = "container_id"
  }

  rule {
    action        = "replace"
    source_labels = ["__meta_docker_container_log_stream"]
    target_label  = "stream"
  }
}

loki.source.docker "containers_logs" {
  host       = "unix:///var/run/docker.sock"
  targets    = discovery.relabel.containers.output
  forward_to = [loki.process.time.receiver]
}




loki.process "time" {
  forward_to = [ loki.write.grafana_loki.receiver ]

  stage.docker {
  }

stage.drop {
    source = "ts"
}


//  stage.timestamp {
//    source = "ts"
//    format = "RFC3339Nano"
//    location = "Europe/Bucharest"
//  }
}

Not sure what you are asking for. Logs have to have timestamp, otherwise how do you know when they happened?

1 Like

ok, how can I make the time UTC+3 then?

Firstly all logs by default should be stored as GMT0. That’s the right way to do it. After storing the Timepicker on Grafana should normally get your browser Timezone (that is get from the OS) and it should be seen with the right correction.

Secondly, if the logs are in GMT0 and the correction isn’t automatic, you should try to look in the timepicker:

Last option should be correcting the log itself, if your case is on this direction you should look at the docs in timestamp | Grafana Loki documentation

Hope it helps.

Browser Time shows UTC+03:00
And in the grafana panel ts=2024-10-11T19:18:07.269384087Z although the current time is 22:18:07

I use alloy, not Promtail

If you want to completely remove the timestamp field from your logs before they are sent to Grafana, you can adjust the processing stage in your loki.process configuration. You already have the stage.drop rule that drops the timestamp field, but it may need a little adjustment. Here’s how you can do it:

loki.process “time” {
forward_to = [ loki.write.grafana_loki.receiver ]

stage.docker {
// You can keep this section if you need it
}

stage.drop {
// Drop the timestamp field
source = “ts”
}

// Additional rule to ensure timestamp is dropped completely
stage.labels {
// Drop timestamp as a label
drop_labels = [“__timestamp”]
}
}

what tz is current timestamp? and what is the real problem you are trying to solve?

In my country the time zone is UTC+3, in the logs stored in Loki UTC+0.
For example, my time is 15:00, and in grafana timestamp 12:00.

I would like to see in grafana timestamp 15:00 (UTC+3)

1 Like

grafana needs timestamps to be UTC. I would leave the timestamp alone as is. Then change your browser to be your local time zone then everything will align

Maybe there are other settings for alloy or loki?
I have been unable to solve this problem for several months(

Other settings to do what?

To set the time

I think you are overthinking this and making it a problem when it’s not.

Two things are true:

  1. You need a timestamp for logs.
  2. In any sort of backend system environment, regardless which part of the world you are, you should want everything to be UTC. You can google why this is generally a good idea.
1 Like

It seems like you want the logs list shown to be in your local time?

That seems reasonable

@tonyswumac do you know why it is in utc? Because if this was visualized in time series it would be in local time but in the list it is still raw utc

I suspect the ts shown in the screenshot is probably not the actual timestamp of the logs, but rather part of the log. I would recommend to make sure logs are properly parsed for timestamp.

1 Like