- What Grafana version and what operating system are you using?
grafana/loki:2.6.1
grafana/promtail:2.6.1
grafana/grafana:9.1.6-ubuntu -
What are you trying to achieve?
My log lines currently have time stamps in the following format20/Sep/2022:09:52:57 +0000
. Currently the timestamps on grafana are being read at scrape (default). I want them to populate with the actual time. -
How are you trying to achieve it?
I am adding a timestamp stage with a custom format. - What happened?
Adding the timestamp stage causes logs to stop appearing when queried. - What did you expect to happen?
Logs would query all the same but with the correct timestamp. - Can you copy/paste the configuration(s) that you are having problems with?
promtail config
server:
http_listen_port: 9080
grpc_listen_port: 0
log_level: debug
positions:
filename: /tmp/positions.yaml
clients:
- url: http://loki:3100/loki/api/v1/push
scrape_configs:
# local machine logs
- job_name: local
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /var/log/*.log
pipeline_stages:
- match:
selector: '{job="varlogs"}'
stages:
- json:
expressions:
time: time_local
- timestamp:
source: time
format: '02/Jan/2006:15:04:05 -0700'
fallback_formats: ['02/Jan/2006:15:04:05 -0700', 'RFC3339']
action_on_failure: skip
Loki Config
auth_enabled: false
server:
http_listen_port: 3100
grpc_listen_port: 9096
log_level: debug
common:
path_prefix: /tmp/loki
storage:
filesystem:
chunks_directory: /tmp/loki/chunks
rules_directory: /tmp/loki/rules
replication_factor: 1
ring:
instance_addr: 127.0.0.1
kvstore:
store: inmemory
schema_config:
configs:
- from: 2020-10-24
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h
ruler:
alertmanager_url: http://localhost:9093
limits_config:
#ingestion_rate_mb: 10
#ingestion_burst_size_mb: 50
reject_old_samples: false
#per_stream_rate_limit: 10MB
#per_stream_rate_limit_burst: 50MB
Promtail logs
level=debug ts=2022-09-26T01:38:19.527634648Z caller=manager.go:265 component=discovery msg="Starting provider" provider=static/0 subs=map[local:{}]
level=debug ts=2022-09-26T01:38:19.527901298Z caller=manager.go:299 component=discovery msg="Discoverer channel closed" provider=static/0
level=info ts=2022-09-26T01:38:19.529054758Z caller=server.go:288 http=[::]:9080 grpc=[::]:39077 msg="server listening on addresses"
level=info ts=2022-09-26T01:38:19.52931686Z caller=main.go:121 msg="Starting Promtail" version="(version=2.6.1, branch=HEAD, revision=6bd05c9a4)"
level=debug ts=2022-09-26T01:38:24.528096622Z caller=filetargetmanager.go:278 msg="new target" labels="{__address__=\"localhost\"}"
level=info ts=2022-09-26T01:38:24.528193572Z caller=filetargetmanager.go:338 msg="Adding target" key="/var/log/*.log:{job=\"varlogs\"}"
level=info ts=2022-09-26T01:38:24.534297631Z caller=filetarget.go:278 msg="watching new directory" directory=/var/log
level=debug ts=2022-09-26T01:38:24.534345771Z caller=filetarget.go:318 msg="tailing new file" filename=/var/log/test.log
ts=2022-09-26T01:38:24.535117494Z caller=log.go:168 level=info msg="Seeked /var/log/test.log - &{Offset:0 Whence:0}"
level=info ts=2022-09-26T01:38:24.53510711Z caller=tailer.go:143 component=tailer msg="tail routine: started" path=/var/log/test.log
level=debug ts=2022-09-26T01:38:24.536870553Z caller=json.go:182 component=file_pipeline component=stage type=json msg="extracted data debug in json stage" extracteddata="map[filename:/var/log/test.log job:varlogs timestamp:17/Sep/2022:09:52:57 +0000]"
level=debug ts=2022-09-26T01:38:24.537055305Z caller=json.go:182 component=file_pipeline component=stage type=json msg="extracted data debug in json stage" extracteddata="map[filename:/var/log/test.log job:varlogs timestamp:17/Sep/2022:09:52:58 +0000]"
level=debug ts=2022-09-26T01:38:24.537138191Z caller=json.go:182 component=file_pipeline component=stage type=json msg="extracted data debug in json stage" extracteddata="map[filename:/var/log/test.log job:varlogs timestamp:17/Sep/2022:09:52:58 +0000]"
level=debug ts=2022-09-26T01:38:24.537679344Z caller=json.go:182 component=file_pipeline component=stage type=json msg="extracted data debug in json stage" extracteddata="map[filename:/var/log/test.log job:varlogs timestamp:17/Sep/2022:09:52:58 +0000]"
Sample Log Line
{"time_local":"17/Sep/2022:09:52:57 +0000","request":"https://test.xyz/v1/client/relay","method":"POST","protocol":"HTTP/1.1","status":"200"}
- Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
I did not spot any errors. - Did you follow any online instructions? If so, what is the URL?
timestamp | Grafana Loki documentation