Skip to content

Commit

Permalink
Add error logs query in Azure (#1192)
Browse files Browse the repository at this point in the history
* Added query for error logs and updated raw logs query

* Updated resource names

* Removed level column

* Removed test logging at startup to reduce noise in azure logs
  • Loading branch information
basiliskus authored Jul 25, 2024
1 parent 9ce9467 commit f782cca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ public static void registerDomains(
Javalin app, Set<Class<? extends DomainConnector>> domainConnectors)
throws UnableToReadOpenApiSpecificationException, DomainConnectorConstructionException {

LOGGER.logInfo("Info");
LOGGER.logWarning("Warning");
LOGGER.logDebug("Debug");
LOGGER.logError("Error");

var instantiatedDomains = new HashSet<DomainConnector>();
for (Class<? extends DomainConnector> domainConnector : domainConnectors) {
DomainConnector connector = constructNewDomainConnector(domainConnector);
Expand Down
14 changes: 12 additions & 2 deletions operations/template/logs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,24 @@ resource "azurerm_log_analytics_query_pack" "application_logs_pack" {
location = data.azurerm_resource_group.group.location
}

resource "azurerm_log_analytics_query_pack_query" "example" {
resource "azurerm_log_analytics_query_pack_query" "application_logs" {
display_name = "TI's Raw Application Logs"
description = "View all TI's application logs in a structured format"

query_pack_id = azurerm_log_analytics_query_pack.application_logs_pack.id
categories = ["applications"]

body = "AppServiceConsoleLogs | extend JsonResult = parse_json(ResultDescription) | project-away TimeGenerated, Level, ResultDescription, Host, Type, _ResourceId, OperationName, TenantId, SourceSystem | evaluate bag_unpack(JsonResult)"
body = "AppServiceConsoleLogs | project JsonResult = parse_json(ResultDescription) | evaluate bag_unpack(JsonResult) | project-reorder ['@timestamp'], level, message"
}

resource "azurerm_log_analytics_query_pack_query" "application_error_logs" {
display_name = "TI's Application Error Logs"
description = "View all TI's application logs with error level in a structured format"

query_pack_id = azurerm_log_analytics_query_pack.application_logs_pack.id
categories = ["applications"]

body = "AppServiceConsoleLogs | project JsonResult = parse_json(ResultDescription) | evaluate bag_unpack(JsonResult) | where level == 'ERROR' | project-away level | project-reorder ['@timestamp'], message"
}

resource "azurerm_monitor_diagnostic_setting" "app_to_logs" {
Expand Down

0 comments on commit f782cca

Please sign in to comment.