### Install Azure Monitor Go modules Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/logs/tutorial-logs-ingestion-code.md Use go get to install the required Azure Monitor Ingestion Logs and Azure Identity client modules. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/monitor/ingestion/azlogs go get github.com/Azure/azure-sdk-for-go/sdk/azidentity ``` -------------------------------- ### Add a time filter to the query Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/logs/get-started-queries.md Example of adding a time filter to a Kusto query. ```Kusto SecurityEvent | where TimeGenerated > ago(30m) | where toint(Level) >= 10 ``` -------------------------------- ### Navigate to the .NET 6 example directory Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/profiler/profiler-containers.md Change directory to the .NET 6 example path. ```bash cd examples/EnableServiceProfilerForContainerAppNet6 ``` -------------------------------- ### Table-based query example Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/logs/get-started-queries.md Returns 10 results from the SecurityEvent table, in no specific order. This common way to get a glance at a table helps you to understand its structure and content. ```Kusto SecurityEvent | take 10 ``` -------------------------------- ### Initialize PerfInsights Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/vm/performance-diagnostics-run.md Navigate to the installation directory and execute the tool to view available parameters. ```console cd PerfInsights ``` -------------------------------- ### Navigate to the container app example directory Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/profiler/profiler-containers.md Change the working directory to the specific example folder for .NET 6 container apps. ```bash cd ApplicationInsights-Profiler-AspNetCore cd examples/EnableServiceProfilerForContainerAppNet6 ``` -------------------------------- ### Casting for numerical comparisons Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/logs/get-started-queries.md Example showing how to cast a string column to a numerical type for comparisons. ```Kusto SecurityEvent | where toint(Level) >= 10 ``` -------------------------------- ### Aggregate groups of rows using summarize Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/logs/get-started-queries.md Example of using the 'summarize' operator with 'count' to aggregate rows. ```Kusto Perf | where TimeGenerated > ago(1h) | summarize count() by ObjectName ``` -------------------------------- ### Clone the sample project repository Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/profiler/profiler-containers.md Use this command to clone the repository containing the container app examples. ```bash git clone https://github.com/microsoft/ApplicationInsights-Profiler-AspNetCore.git ``` -------------------------------- ### Example of creating AKS extension with full configuration Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/containers/kubernetes-monitoring-enable-arc.md This example demonstrates a complete `az k8s-extension create` command with specific resource IDs for Azure Monitor and Grafana workspaces. ```azurecli az k8s-extension create --name azuremonitor-metrics --cluster-name "my-cluster"--resource-group "my-resource-group" --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers.Metrics --configuration-settings azure-monitor-workspace-resource-id "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/my-resource-group/providers/microsoft.monitor/accounts/my-workspace" grafana-resource-id="/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/my-resource-group/providers/Microsoft.Dashboard/grafana/my-workspace" ``` -------------------------------- ### Define and use custom fields with extend Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/logs/get-started-queries.md Example of using the 'extend' operator to add a custom column. ```Kusto SecurityEvent | top 10 by TimeGenerated | extend EventCode=substring(Activity, 0, 4) ``` -------------------------------- ### Log count per log starting with Dicom100 error code and CorrelationId Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/reference/queries/ahdsdicomdiagnosticlogs.md Get the count of logs starting with Dicom100 error emitted from Dicom service per CorrelationId. The result contains count by CorrelationId. ```kql AHDSDicomDiagnosticLogs | where Message startswith "DICOM100:" | summarize Count = count() by CorrelationId ``` -------------------------------- ### Example configuration error output Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/containers/container-insights-prometheus-logs.md Sample output indicating an unsupported or missing configuration schema version. ```text ***************Start Config Processing******************** config::unsupported/missing config schema version - 'v21' , using defaults ``` -------------------------------- ### Initialize PerfInsights on Linux Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/vm/performance-diagnostics-run.md Navigate to the PerfInsights directory and execute the script to view available command-line parameters. ```bash cd sudo python perfinsights.py ``` -------------------------------- ### Where operator Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/logs/get-started-queries.md Use the `where` operator to filter query results. This example returns only `SecurityEvent` records where `Level equals _8`. ```Kusto SecurityEvent | where Level == 8 ``` -------------------------------- ### Helm Release Output Example Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/containers/kubernetes-monitoring-disable.md Example output showing the status of the azmon-containers-release-1 chart. ```text NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION azmon-containers-release-1 default 3 2020-04-21 15:27:24.1201959 -0700 PDT deployed azuremonitor-containers-2.7.0 7.0.0-1 ``` -------------------------------- ### Include or exclude columns in query results using project Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/logs/get-started-queries.md Example of using the 'project' operator to select specific columns. ```Kusto SecurityEvent | top 10 by TimeGenerated | project TimeGenerated, Computer, Activity ``` -------------------------------- ### Search query example Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/logs/get-started-queries.md Searches the SecurityEvent table for records that contain the phrase "Cryptographic." Of those records, 10 records are returned and displayed. ```Kusto search in (SecurityEvent) "Cryptographic" | take 10 ``` -------------------------------- ### Configuration file example Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/app/java-standalone-config.md This example shows what a configuration file looks like with multiple components. Configure specific options based on your needs. ```json { "connectionString": "...", "role": { "name": "my cloud role name" }, "sampling": { "percentage": 100 }, "jmxMetrics": [ ], "customDimensions": { }, "instrumentation": { "logging": { "level": "INFO" }, "micrometer": { "enabled": true } }, "proxy": { }, "preview": { "processors": [ ] }, "selfDiagnostics": { "destination": "file+console", "level": "INFO", "file": { "path": "applicationinsights.log", "maxSizeMb": 5, "maxHistory": 1 } } } ``` -------------------------------- ### Include or exclude columns in query results using project with renaming and new columns Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/logs/get-started-queries.md Example of using 'project' to rename columns and define new ones. ```Kusto SecurityEvent | top 10 by TimeGenerated | project Computer, TimeGenerated, EventDetails=Activity, EventCode=substring(Activity, 0, 4) ``` -------------------------------- ### Build and Run Docker Container Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/profiler/profiler-containers.md Commands to build the Docker image and start the container instance. ```bash docker build -t profilerapp . ``` ```bash docker run -d -p 8080:80 --name testapp profilerapp ``` -------------------------------- ### Top operator Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/logs/get-started-queries.md Use the `top` operator to sort the entire table on the server side and then return the top records. This example returns the latest 10 records. ```Kusto SecurityEvent | top 10 by TimeGenerated ``` -------------------------------- ### Get Started with Application Insights JavaScript SDK Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/fundamentals/whats-new.md A quick and easy method to get started with the Azure Monitor Application Insights JavaScript SDK. ```javascript ``` -------------------------------- ### Create a new MVC project Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/profiler/profiler-containers.md Initialize a new ASP.NET Core MVC project using the .NET CLI. ```powershell dotnet new mvc -n EnableServiceProfilerForContainerApp ``` -------------------------------- ### Install and start cron service on RHEL/CentOS Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/agents/agent-linux-troubleshoot.md Install cron service binaries and start the service on RHEL/CentOS systems. ```bash # To Install the service binaries sudo yum install -y crond # To start the service sudo service crond start ``` -------------------------------- ### Dockerfile example for Application Insights Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/app/java-get-started-supplemental.md A Dockerfile example demonstrating how to copy the Application Insights agent JAR, configuration file, and set the connection string environment variable. ```dockerfile FROM ... COPY target/*.jar app.jar COPY agent/applicationinsights-agent-3.7.8.jar applicationinsights-agent-3.7.8.jar COPY agent/applicationinsights.json applicationinsights.json ENV APPLICATIONINSIGHTS_CONNECTION_STRING="CONNECTION-STRING" ENTRYPOINT["java", "-javaagent:applicationinsights-agent-3.7.8.jar", "-jar", "app.jar"] ``` -------------------------------- ### KEDA Pods Status Example Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/containers/integrate-keda.md This is an example output showing the status of KEDA pods. All pods should be in a 'Running' state. ```bash NAME READY STATUS RESTARTS AGE keda-admission-webhooks-ffcb8f688-kqlxp 1/1 Running 0 4m keda-operator-5d9f7d975-mgv7r 1/1 Running 1 (4m ago) 4m keda-operator-metrics-apiserver-7dc6f59678-745nz 1/1 Running 0 4m ``` -------------------------------- ### Install and start cron service on SUSE Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/agents/agent-linux-troubleshoot.md Install cron service binaries and start the service on SUSE systems. ```bash # To Install the service binaries sudo zypper in cron -y # To start the service sudo systemctl enable cron sudo systemctl start cron ``` -------------------------------- ### Install and start cron service on Ubuntu/Debian Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/agents/agent-linux-troubleshoot.md Install cron service binaries and start the service on Ubuntu/Debian systems. ```bash # To Install the service binaries sudo apt-get install -y cron # To start the service sudo service cron start ``` -------------------------------- ### List VMs by Availability and Power State (KQL) Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/service-health/includes/resource-health.md Use this KQL query to retrieve virtual machines and summarize their health by power and availability states. It includes resource group and resource ID for detailed visibility. Excludes deallocated virtual machines. ```kusto Resources | where type =~ 'microsoft.compute/virtualmachines' | project resourceGroup, Id = tolower(id), PowerState = tostring( properties.extended.instanceView.powerState.code) | join kind=leftouter ( HealthResources | where type =~ 'microsoft.resourcehealth/availabilitystatuses' | where tostring(properties.targetResourceType) =~ 'microsoft.compute/virtualmachines' | project targetResourceId = tolower(tostring(properties.targetResourceId)), AvailabilityState = tostring(properties.availabilityState)) on $left.Id == $right.targetResourceId | project-away targetResourceId | where PowerState != 'PowerState/deallocated' ``` -------------------------------- ### Install and start cron service on Oracle Linux Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/agents/agent-linux-troubleshoot.md Install cron service binaries and start the service on Oracle Linux systems. ```bash # To Install the service binaries sudo yum install -y cronie # To start the service sudo service crond start ``` -------------------------------- ### Install .NET client libraries Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/logs/tutorial-logs-ingestion-code.md Install the Azure Monitor Ingestion client library and the Azure Identity library. The Azure Identity library is required for authentication. ```dotnetcli dotnet add package Azure.Identity dotnet add package Azure.Monitor.Ingestion ``` -------------------------------- ### Install Dependency Agent on Linux Source: https://github.com/microsoftdocs/azure-monitor-docs/blob/main/articles/azure-monitor/vm/vminsights-dependency-agent.md Run the installer script with sudo privileges to install or upgrade the Dependency Agent on a Linux machine. Check logs in /var/opt/microsoft/dependency-agent/log if it fails to start. ```bash sudo /InstallDependencyAgent-Linux64.bin ```