Following Naveen's advice, I firstly used Event Subscriptions and system topics (Azure Event Grid) to receive events when blob files get added to storage accounts.
Configuring the "azure_event_hubs" as above allowed Promtail to forward logs to Loki whenever blob events trigger, but this meant I did not get the content of the logs stored as JSON files on the storage containers.
In order to get the Azure diagnostic log entries, I chose "Stream to an event hub" option in Azure Diagnostic settings:
eh as destination for diagnostic logs
Here you can specify which log categories you are interested in.
Then I adjusted the Promtail configuration as follows:
- job_name: azure_event_hubs
azure_event_hubs:
fully_qualified_namespace: ehns.servicebus.windows.net:9093
connection_string: connection-string
event_hubs: eh-name
labels:
job: azure_event_hub
relabel_configs:
- action: replace
source_labels:
- __azure_event_hubs_category
target_label: category
as in promtail config
I did not need a forward_to attribute, because I do not use Grafana flow.
I am now able to receive Azure Diagnostic Logs directly from Azure in Loki and can query them in Grafana with "categroy" and "job" as labels.
Under Promtail, azure_event_hubs can now be seen as a target:
promtail targets
The only disadvantage to this is that basic pricing plan Azure Event Hubs cannot be used, but rather standard pricing and above.
While this approach solves my problem indeed, I still want to minimize the costs. Therefore, I will search if I can replace Azure Even Hub (as a destination for azure Diagnostic Logs) with:
1- a Kafka instance that is not connected to an Azure event hub.
2- or by archiving in storage accounts (most cost-effective approach) and find a way to extract the log entries from there and ingest them to Loki.
Azure diagnostic settings allow sending to a partner solution, but I have not tried it out yet.
Edit:
A more cost-effective approach:
The storage account blob container can get mounted to a directory of a second Promtail instance (as suggested here).
On promtail.yaml config yaml, add a new job with its static_configs section of the "scrape_configs" directing Promtail to read from the mounted directory (e.g., /var/log) as follows:
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlog
__path__: /var/log/**/*.log
Unlike the first approach which streams live log entries directly from azure diagnostic logs using an event hub, the second approach reads archived files that already got written to cold storage (indirectly - even the logs got written to azure storage accounts a while ago).