Read AppServiceConsoleLogs and push to Blob Storage container/table
BalaKrishna Mahamkali
0
Reputation points
Hello Team,
we have a webapp python Django based. We are generating custom logs for user actions using code below.
Settings.py:
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"formatter_ABC": {
"format": "ABC {levelname};{message}",
"style": "{"
}
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
},
"console_ABC": {
"level": "INFO",
"class": "logging.StreamHandler",
"formatter": "formatter_ABC"
}
},
"root": {
"handlers": ["console"],
"level": "WARNING"
},
"loggers": {
"ABC": {
"handlers": ["console_ABC"],
"level": "INFO",
"propagate": False,
}
}
```}
app.py:importing:
import logging
ABC_logger = logging.getLogger('ABC')
#user action
ABC_logger.info("user action")
Now, these user action logs i can see in "AppServiceConsoleLogs".
Currently, we are doing the following manual step:
Login to Azure portal
Select proper orchestrator service depending on which environment you target
UAT: webapp-uat-test-python-django-app
Select Logs in Monitoring section
Select desired time range(one week)
Copy below query in KQL mode:
AppServiceConsoleLogs
| project TimeGenerated, ResultDescription
| where ResultDescription hasprefix "ABC INFO"
| order by TimeGenerated desc
export the data as CSV once loaded & share with Qlinksense team.
As per the security approach, we dont store the logs directly in blob storage.
We want to avoid this manual process and make it automatic daily.
We have two storage account one is specific BLOB srorages and other is for Data Lake Storage something.
We created a container & table for in BLOB storage account and one more ADDS container in data-lake storage account.
So, now i want to know how to read and push the AppServiceConsoleLogs logs and filter them by "ABC INFO" and consolidated logs to both storages daily job.
As far as i discussed internally, people are say use triggers job or functions apps to do that.
But i am not sure which is the correct way.
if there is any alternative way with less config/services. Please let me know.
Please share examples links if any.
thanks,
Bala Krishna
Sign in to answer