Read data file from file system

Hi! I want to copy raw data from Loki to process it alongside Python(preferably) or Golang. My Loki instance is configured this way.

auth_enabled: false
chunk_store_config:
  max_look_back_period: 168h
compactor:
  shared_store: filesystem
  working_directory: /logs/loki/boltdb-shipper-compactor
ingester:
  chunk_block_size: 262144
  chunk_idle_period: 3m
  chunk_retain_period: 1m
  lifecycler:
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
  max_transfer_retries: 0
limits_config:
  enforce_metric_name: false
  ingestion_burst_size_mb: 32
  ingestion_rate_mb: 24
  reject_old_samples: true
  reject_old_samples_max_age: 168h
querier:
  engine:
    max_look_back_period: 3m
    timeout: 10m
  query_timeout: 10m
query_range:
  parallelise_shardable_queries: true
  split_queries_by_interval: 30m
schema_config:
  configs:
  - chunks:
      period: 24h
      prefix: chunk_
    from: "2020-10-24"
    index:
      period: 24h
      prefix: index_
    object_store: gcs
    schema: v11
    store: boltdb-shipper
  - chunks:
      period: 24h
      prefix: chunk_
    from: "2022-10-27"
    index:
      period: 24h
      prefix: index_
    object_store: filesystem
    schema: v11
    store: boltdb-shipper
server:
  http_listen_port: 3100
storage_config:
  boltdb_shipper:
    active_index_directory: /logs/loki/boltdb-shipper-active
    cache_location: /logs/loki/boltdb-shipper-cache
    cache_ttl: 24h
    shared_store: filesystem
  filesystem:
    directory: /logs
  gcs:
    bucket_name: valhalla-loki
table_manager:
  retention_deletes_enabled: true
  retention_period: 168h

Am I right that I need to use the BoltDB library to read content from such files?

/logs/ZmFrZS9mZjQ2OGI2MzQwZXyZZTA6MTk0YWI4OGY3ZGE6MTk0YWI4OGY3ZGI6ZjY5NDZlZDE=

I’m asking because getting error using Golang “GitHub - boltdb/bolt: An embedded key/value database for Go.

For those who will be looking for it after me. There a code example in loki/cmd/segment-inspect at main · grafana/loki · GitHub for the Golang Loki segment reading/validating .

I would recommend you to use the API instead of reading chunk files directly, unless you have a reason to do so. You can probably use the code for LogCLI (written in golang i believe).