How to configure loki.yml to use Azure's blob storage

On my local server , I want Loki to use Azue’s blob storage. The configuration of loki.yml is as follows:

storage_config:
  tsdb_shipper:
  active_index_directory: /www/loki-data/index
  cache_location: /www/loki-data/index_cache
  cache_ttl: 24h
  azure:
    account_name: test
    account_key: "c3A9eGFkdCZzdD0yMDI0LTA3LTA1VDA2OjA5OjAzWiZzZT0yMDI0LTEyLTMxVDE2OjAwOjAwWiZzcHI9aHR0cHMmc3Y9MjAyMi0xMS0wMiZzcj1jJnNpZz1BbHNnSGZhTG43RDhlNSUyRjB5JTJGbG5IN1UlMkZ4UUFoTkVxUmJwYWxVWEpERXd3JTNECg==" # This is the value after base64 encoding
    container_name: loki-test
    use_managed_identity: false
    request_timeout: 0

schema_config:
  configs:
    - from: 2022-06-25
      store: tsdb
      object_store: azure
      schema: v13
      index:
        prefix: baoyu_
        period: 24h

But after startup, an error occurred later. It seems that authentication failed when flashing the data block to the blob:

level=error ts=2024-07-06T08:30:44.210879035Z caller=cached_client.go:189 msg="failed to build table names cache" err="-> github.com/Azure/azure-storage-blob-go/azblob.newStorageError, /src/loki/vendor/github.com/Azure/azure-storage-blob-go/azblob/zc_storage_error.go:42
===== RESPONSE ERROR (ServiceCode=AuthenticationFailed) =====
Description=Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:332d6727-901e-005e-207e-cf95b3000000
Time:2024-07-06T08:30:44.2355215Z, Details:
AuthenticationErrorDetail: The MAC signature found in the HTTP request 'D3OqVRtAo/s7farP1aumFCx7HcVlxdQ60BSHvwopOSo=' is not the same as any computed signature. Server used following string to sign: 'GET

x-ms-client-request-id:0964a3aa-b9ac-4b65-7922-8e6e34f8a600
x-ms-date:Sat, 06 Jul 2024 08:30:44 GMT
x-ms-version:2020-04-08
/test/loki-test
comp:list
delimiter:/
prefix:index/
restype:container
timeout:61'.
Code: AuthenticationFailed
GET https://test.blob.core.windows.net/loki-test?comp=list&delimiter=%2F&prefix=index%2F&restype=container&timeout=61
Authorization: REDACTED
User-Agent: [Azure-Storage/0.14 (go1.21.3; linux)]
X-Ms-Client-Request-Id: [0964a3aa-b9ac-4b65-7922-8e6e34f8a600]
X-Ms-Date: [Sat, 06 Jul 2024 08:30:44 GMT]
X-Ms-Version: [2020-04-08]
RESPONSE Status: 403 Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
Content-Length: [777]
Content-Type: [application/xml]
Date: [Sat, 06 Jul 2024 08:30:43 GMT]
Server: [Microsoft-HTTPAPI/2.0]
X-Ms-Error-Code: [AuthenticationFailed]
X-Ms-Request-Id: [332d6727-901e-005e-207e-cf95b3000000]
"

My account name and account key can be uploaded to blob storage on the same server using the az command (azured command-line client), indicating that account name and account key are correct. for example :
az storage blob upload --container-name loki-test --account-name test --account-key ‘xxxxxxx’ --file test.txt
My Loki version: 2.9.8

How can I configure loki.yml to use Azure’s blob storage?

Hi @baoyu05 and welcome to the Grafana Community :slight_smile:

It should work. I still use boltdb_shipper, for which I set the “shared_store” to “azure” as in here

The rest is configured as in the Azure example.

storage_config:
  boltdb_shipper:
    active_index_directory: /var/loki/index						
    cache_location: /var/loki/cache								
    cache_ttl: 168h								
    shared_store: azure
  azure:														
    account_name: account_name
    account_key: account_key
    container_name: container_name

hi, if possible, please could you share the complete yaml, which will be helpful. thanks