How can i configure Timezone when use HTTP API send logs to Loki?

System Date :

Local time: 四 2021-08-05 13:23:24 CST
Universal time: 四 2021-08-05 05:23:24 UTC
RTC time: 四 2021-08-05 05:23:23
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a

System Time zone is CST

when i use HTTP API /loki/api/v1/push send log to Loki, Response is :

entry with timestamp 2021-08-04 06:01:34.268 +0000 UTC ignored, reason: ‘entry out of order’ for stream: {host=“devconsul.drcuiyutao.com”},

it seems like UTC is the default Time zone , but System Time Zone is CST.

Hi @lichao4java

Are you using a timestamp stage in promtail?
Please send through your config.

i do not use promtail collect logs, i use HTTP API send logs to Loki.

such as:


curl -v -H "Content-Type: application/json" -XPOST -s "http://192.168.8.64:3100/loki/api/v1/push" --data-raw \ '{ "streams":[ { "stream":{ "host":"devconsul.drcuiyutao.com" }, "values":[ [ "1628042013000000000", "\"-\" 192.168.8.206 - - [04/Aug/2021:14:01:28 +0800] devconsul.d.com \"GET /v1/health/service/yxy-upload-api-bak?recurse&index=4557432 HTTP/1.0\" 504 176 \"-\" \"-\" 192.168.8.206:8500 GET 504 200.000" ] ] }, { "stream":{ "host":"devconsul.drcuiyutao.com" }, "values":[ [ "1628042013000000000", "\"-\" 192.168.8.211 - - [04/Aug/2021:14:01:28 +0800] devconsul.d.com \"GET /v1/agent/services HTTP/1.1\" 200 4420 \"-\" \"okhttp/3.12.2\" 192.168.8.206:8500 GET 200 0.002" ] ] } ] }'

And response is:

entry with timestamp 2021-08-04 01:53:33 +0000 UTC ignored, reason: 'entry out of order' for stream: {host="devconsul.d.com"},

total ignored: 1 out of 1

This is my loki-local-config.yaml :

auth_enabled: false

server:
  http_listen_port: 3100
  grpc_listen_port: 9096

ingester:
  wal:
    enabled: true
    dir: /data/Application/wal
  lifecycler:
    address: 0.0.0.0
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
    final_sleep: 0s
  chunk_idle_period: 1h       # Any chunk not receiving new logs in this time will be flushed
  max_chunk_age: 1h           # All chunks will be flushed when they hit this age, default is 1h
  chunk_target_size: 1048576  # Loki will attempt to build chunks up to 1.5MB, flushing first if chunk_idle_period or max_chunk_age is reached first
  chunk_retain_period: 30s    # Must be greater than index read cache TTL if using an index cache (Default index read cache TTL is 5m)
  max_transfer_retries: 0     # Chunk transfers disabled

schema_config:
  configs:
    - from: 2020-10-24
      store: boltdb-shipper
      object_store: filesystem
      schema: v11
      index:
        prefix: index_
        period: 24h

storage_config:
  boltdb_shipper:
    active_index_directory: /data/Application/loki/boltdb-shipper-active
    cache_location: /data/Application/loki/boltdb-shipper-cache
    cache_ttl: 24h         # Can be increased for faster performance over longer query periods, uses more disk space
    shared_store: filesystem
  filesystem:
    directory: /data/Application/loki/chunks

compactor:
  working_directory: /data/Application/loki/boltdb-shipper-compactor
  shared_store: filesystem

limits_config:
  reject_old_samples: true
  reject_old_samples_max_age: 168h

chunk_store_config:
  max_look_back_period: 0s

table_manager:
  retention_deletes_enabled: false
  retention_period: 0s

ruler:
  storage:
    type: local
    local:
      directory: /data/Application/loki/rules
  rule_path: /data/Application/loki/rules-temp
  alertmanager_url: http://localhost:9093
  ring:
    kvstore:
      store: inmemory
  enable_api: true

is anyone else ??? 20 words

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.