I am exploring to monitor VPN Tunnel status using Azure Monitor via Azure Monitor metrics Exporter(https://github.com/webdevops/azure-metrics-exporter). Monitoring Stack is Victoria Metrics + Grafana. Currently We are using Diagnostic logs to fetch the S2S Tunnel Status using below query and sending the alerts over mail+webhook to the Dispatcher team.
AzureDiagnostics
| where TimeGenerated > ago(5m)
| where Category == "TunnelDiagnosticLog" and OperationName == "TunnelDisconnected"
| project
TimeGenerated,
Resource,
status_s,
remoteIP_s,
stateChangeReason_s,
OperationName
How can we onboard this alert for S2S Tunnel status on my existing solution to make it automated and more efficient?
While going through the metrics offered by Azure Monitor(https://learn.microsoft.com/en-us/azure/vpn-gateway/vpn-gateway-howto-setup-alerts-virtual-network-gateway-metric) I couldn’t find any metric related to my problem. Any kind of help is much appreciated
2
Answers
I created one S2S VPN connection in my Azure Environment
S2S connection connected successfully :-
I enabled the logging for Virtual Network Gateway and created diagnostics settings:-
Sent logs to Log analytics workspace:-
If you cannot find the required metrics or want to create an alert based on the query in the question, You can select Custom logs in the Alert and then provide your query to create an alert based on the query result.
Go to your Log analytics workspace that contains your VPN logs.
Select Log Analytics Workspace > Alerts > Create Alert > Condition > Custom log search > Type your Log query > Create an Alert
You can select Webhook below :-
Provide your Webhook URL and create an Alert.
I might recommend investigating which metrics are exported by https://github.com/webdevops/azure-metrics-exporter and check if the right metrics are present in the Azure Monitor managed service, as the documentation may be out of date. If metrics are present – then just configure https://docs.victoriametrics.com/vmalert.html and it should works.