I'm trying to get the default Service Fabric app logging to work in Azure the same way it does locally.
In Visual Studio 2019 v16.4.5 I created the sample Service Fabric stateless application .Net Core 3.1.
Everything built and runs locally OK.
In the Diagnostics Event window I can see the application log messages "Working-1522" this if from the sample source code:
ServiceEventSource.Current.ServiceMessage(this.Context, "Working-{0}", ++iterations);
But.. When I deploy to Azure it deploys OK and runs OK but I no longer see the "Working-1522" messages in any of the storage WADServiceFabricSystemEventTable or WADServiceFabricReliableServiceEventTable tables.
I don't see the messages anywhere.
I am not using Application Insights. The nodes have the IaaSDiagnostics Microsoft.Azure.Diagnostics Extension, with these Settings:
{
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"overallQuotaInMB": "50000",
"sinks": "applicationInsights",
"EtwProviders": {
"EtwEventSourceProviderConfiguration": [
{
"provider": "Microsoft-ServiceFabric-Actors",
"scheduledTransferKeywordFilter": "1",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableActorEventTable"
}
},
{
"provider": "Microsoft-ServiceFabric-Services",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableServiceEventTable"
}
}
],
"EtwManifestProviderConfiguration": [
{
"provider": "cbd93bc2-71e5-4566-b3a7-595d8eeca6e8",
"scheduledTransferLogLevelFilter": "Information",
"scheduledTransferKeywordFilter": "4611686018427387904",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricSystemEventTable"
}
}
]
}
},
"SinksConfig": {
"Sink": [
{
"name": "applicationInsights",
"ApplicationInsights": ""
}
]
}
},
"StorageAccount": "wad34xxxxxxxxxxx"
}
Any Suggestions?
Did you follow this walkthrough?
You seem to be missing the storage account details:
"type": "IaaSDiagnostics",
"autoUpgradeMinorVersion": true,
"protectedSettings": {
"storageAccountName": "[parameters('applicationDiagnosticsStorageAccountName')]",
"storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('applicationDiagnosticsStorageAccountName')),'2015-05-01-preview').key1]",
"storageAccountEndPoint": "https://core.windows.net/"
},
Related
I'm currently implementing Azure Application Insights logging with Serilog which is working fine except for when I use an output template in my Serilog configuration. It seems like the template is ignored when passing the Serilog data to Application insights.
My serilog config in appsetting.json:
"Serilog": {
"Using": [ "Serilog.Sinks.ApplicationInsights" ],
"MinimumLevel": "Debug",
"WriteTo": [
{ "Name": "Console" },
{
"Name": "RollingFile",
"Args": {
"pathFormat": "logs\\log-{Date}.txt",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"
}
},
{
"Name": "ApplicationInsights",
"Args": {
"restrictedToMinimumLevel": "Information",
"telemetryConverter": "Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights",
"outputTemplate": "Test Template - {Message}"
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Properties": {
"Application": "app"
}
},
The logging statement:
logger.Error("Test Serilog Error For AI - " + DateTime.Now);
The output within application insights:
Is this the correct approach to customising an error message for Application insights?
After checking the source code serilog-sinks-applicationinsights, you will find it did not read the outputTemplate from appsetting.json.
For a workaround, you may implement custom TemplateTraceTelemetryConverter.
TemplateTraceTelemetryConverter
public class TemplateTraceTelemetryConverter : TraceTelemetryConverter
{
public override IEnumerable<ITelemetry> Convert(LogEvent logEvent, IFormatProvider formatProvider)
{
var templateParser = new MessageTemplateParser();
var template = templateParser.Parse($"Test Template - {logEvent.MessageTemplate.Text}");
LogEvent newLogEvent = new LogEvent(logEvent.Timestamp
, logEvent.Level
, logEvent.Exception
, template
, logEvent.Properties.Select(p => new LogEventProperty(p.Key, p.Value)));
return base.Convert(newLogEvent, formatProvider);
}
}
Use TemplateTraceTelemetryConverter
"Serilog": {
"Using": [
"Serilog.Sinks.ApplicationInsights",
],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "Test Template - {Message}"
}
},
{
"Name": "RollingFile",
"Args": {
"pathFormat": "logs\\log-{Date}.txt",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"
}
},
{
"Name": "ApplicationInsights",
"Args": {
"restrictedToMinimumLevel": "Error",
"telemetryConverter": "YourProjectNamespace.TemplateTraceTelemetryConverter, YourProjectNamespace"
//"outputTemplate": "Test Template - {Message}"
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Properties": {
"Application": "app"
}
}
I am trying to setup enable diagnostics logs for app service using portal, which is working fine as below :
The same settings i am trying create using ARM Template but it is not working.
My ARM Template looks like below :
Is there anything wrong with settings or any other ways to enable logs ?
Anyone help is appreciated.
Regards,
Dipti Mamidala
In the resources array of the resource for which you want to enable Diagnostic Logs, add a resource of type [resource namespace]/providers/diagnosticSettings.
Example :
"resources": [
{
"type": "providers/diagnosticSettings",
"name": "[concat('Microsoft.Insights/', parameters('settingName'))]",
"dependsOn": [
"[/*resource Id for which Diagnostic Logs will be enabled>*/]"
],
"apiVersion": "2017-05-01-preview",
"properties": {
"name": "[parameters('settingName')]",
"storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]",
"eventHubAuthorizationRuleId": "[parameters('eventHubAuthorizationRuleId')]",
"eventHubName": "[parameters('eventHubName')]",
"workspaceId": "[parameters('workspaceId')]",
"logs": [
{
"category": "/* log category name */",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]
}
}
]
Read more here in documentation
Update : To set the value of Web Server logging use the below example
"properties": {
"applicationLogs": {
"Storage": {
"level": "Verbose"
}
},
"httpLogs": {
"fileSystem": {
}
}
}
If you want Storage or fileSystem use any one of above
I got this working by setting the httpLogs and httpLoggingEnabled properties.
This is the config resource nested within a site resource:
"resources": [
{
"apiVersion": "2018-02-01",
"type": "config",
"name": "logs",
"dependsOn": [
"[concat('Microsoft.Web/sites/', parameters('name'))]"
],
"properties": {
"applicationLogs": {
"azureBlobStorage": {
"level": "information",
"retentionInDays": 15
}
},
"httpLogs": {
"fileSystem": {
"retentioninMb": 35,
"retentioninDays": 15,
"enabled": true
}
},
"requestTracingEnabled": true,
"requestTracingExpirationTime": "9999-12-31T23:59:00Z",
"remoteDebuggingEnabled": false,
"httpLoggingEnabled": true,
"logsDirectorySizeLimit": 34,
"detailedErrorLoggingEnabled": true
}
}
]
I'm trying to send performance data (i.e. CPU and Memory Usage) from my service fabric nodes to Azure Application Insights. However they do not seem to be appearing in my application insights metrics explorer.
The performance counters are successfully sent to to an azure storage table (WADPerformanceCountersTable) but are not propagated onto application insights for analysis.
Here is the WAD Config part of my resource file which is used to deploy my service fabric application:
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"overallQuotaInMB": "50000",
"sinks": "applicationInsights",
"DiagnosticInfrastructureLogs": {},
"PerformanceCounters": {
"PerformanceCounterConfiguration": [
{
"counterSpecifier": "\\Processor(_Total)\\% Processor Time",
"sampleRate": "PT3M",
"sinks": "applicationInsights"
},
{
"counterSpecifier": "\\Memory\\Available MBytes",
"sampleRate": "PT3M",
"sinks": "applicationInsights"
}
]
},
"EtwProviders": {
"EtwEventSourceProviderConfiguration": [
{
"provider": "Microsoft-ServiceFabric-Actors",
"scheduledTransferKeywordFilter": "1",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableActorEventTable"
}
},
{
"provider": "Microsoft-ServiceFabric-Services",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableServiceEventTable"
}
}
],
"EtwManifestProviderConfiguration": [
{
"provider": "cbd93bc2-71e5-4566-b3a7-595d8eeca6e8",
"scheduledTransferLogLevelFilter": "Information",
"scheduledTransferKeywordFilter": "4611686018427387904",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricSystemEventTable"
}
}
]
}
},
"SinksConfig": {
"Sink": [
{
"name": "applicationInsights",
"ApplicationInsights": "c0c27fcd-21e8-4a11-8502-ed250d22e124"
}
]
}
},
"StorageAccount": "sfdgbriansftest7053"
Is there anything I am missing from this deployment file to successfully receive these performance counters? Am I missing any other required steps?
Thanks.
I have this working in my cluster. I am sending CPU usage to application insights. Please see the json below. The only difference I can see is that you are not specifying the "units" and the "scheduledTransferPeriod".
"publisher": "Microsoft.Azure.Diagnostics",
"settings": {
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"overallQuotaInMB": "50000",
"sinks": "applicationInsights",
"PerformanceCounters": {
"scheduledTransferPeriod": "PT1M",
"PerformanceCounterConfiguration": [
{
"counterSpecifier": "\\Processor(_Total)\\% Processor Time",
"sampleRate": "PT15S",
"unit": "Percent",
"annotation": [
],
"sinks": "applicationInsights"
}
]
},
I'm deploying an Azure Web App using the Microsoft.Azure.Management.Websites SDK.
I can create the web app fine with WebSiteManagementClient.Sites.CreateOrUpdateSite(). However one element that I can't seem to configure is the Diagnostics logging.
In the new Azure Portal, I can open "Diagnostics logs" and define both the "Application Logging" and "Web server logging" to use Blob storage.
I'm unable to see any options in the SDK libraries for configuring this - anyone have any ideas? I'm open to using ARM Templates if need be.
Thanks in advance
Solved : The method WebSiteManagementClient.Sites.UpdateSiteLogsConfig() is where the diagnostics get defined
Alternatively, you can also configure the diagnostic logs to enable the use of blob storage for logging for web app with the ARM template section below.
{
"type": "Microsoft.Web/sites",
"name": "[parameters('webapp_name')]",
"apiVersion": "2015-08-01",
"location": "Southeast Asia",
"properties": {
"name": "[parameters('webapp_name')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_name'))]"
},
"resources": [
{
"name": "logs",
"type": "config",
"apiVersion": "2015-08-01",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('webapp_name'))]"
],
"properties": {
"applicationLogs": {
"fileSystem": {
"level": "Off"
},
"azureTableStorage": {
"level": "Off",
"sasUrl": null
},
"azureBlobStorage": {
"level": "Verbose",
"sasUrl": "yourBlobStorageSasUrl",
"retentionInDays": null
},
"httpLogs": {
"fileSystem": {
"retentionInMb": 35,
"retentionInDays": null,
"enabled": false
},
"azureBlobStorage": {
"sasUrl": "yourBlobStorageSasUrl",
"retentionInDays": null,
"enabled": true
}
}
}
}
}
],
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_name'))]"
]
}
I want to scale out or scale in the service fabric application. For this I have added the autoscalesettings with CPU metric on VM scale set. And in VM scale set, I have the extension section with wadcfg section with counter on CPU metric. And the data is successfully getting emitted to storage account which I have specified.But scale out or scale on options are not getting done with VMSS and service fabric cluster. I have gone through trouble shooting steps which were specified in azure portal.https://azure.microsoft.com/en-us/documentation/articles/virtual-machine-scale-sets-troubleshoot/
And without service fabric, the same CPU metric is working fine and VM scale set is getting scale out.
Checked subscription limit as well. But could not able to find the issue. But, we are getting a mail notification saying, could not able to read the diagnostics data for autoscale when vmss and service fabric together deployed.
Service Fabric does support AutoScale it's just not very well documented. Here is a basic documentation - https://azure.microsoft.com/en-us/documentation/articles/service-fabric-cluster-scale-up-down/ which uses "XmlCfg" element to configure counters. However there is a way to do it via JSON as well which is more readable. Here is a snippet of a "settings" block from "IaaSDiagnostics" extension.
Note the inclusion of "PerformanceCounters" and "Metrics" elements under "DiagnosticMonitorConfiguration".
{
"name": "Windows_VMDiagnosticsVmExt",
"properties": {
"type": "IaaSDiagnostics",
"autoUpgradeMinorVersion": true,
"protectedSettings": {
"storageAccountName": "[variables('applicationDiagnosticsStorageAccountName')]",
"storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('applicationDiagnosticsStorageAccountName')),'2016-01-01').keys[0].value]",
"storageAccountEndPoint": "https://core.windows.net/"
},
"publisher": "Microsoft.Azure.Diagnostics",
"settings": {
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"overallQuotaInMB": "50000",
"PerformanceCounters": {
"PerformanceCounterConfiguration": [
{
"annotation": [],
"scheduledTransferPeriod": "PT1M",
"counterSpecifier": "\\Processor(_Total)\\% Processor Time",
"sampleRate": "PT1M"
},
{
"annotation": [],
"scheduledTransferPeriod": "PT1M",
"counterSpecifier": "\\Memory\\% Committed Bytes in Use",
"sampleRate": "PT1M"
}
]
},
"Metrics": {
"resourceId": "[resourceId('Microsoft.Compute/virtualMachineScaleSets', variables('defaultVMNodeTypeName'))]",
"MetricAggregation": [
{ "scheduledTransferPeriod": "PT1H" },
{ "scheduledTransferPeriod": "PT1M" }
]
},
"EtwProviders": {
"EtwEventSourceProviderConfiguration": [
{
"provider": "Microsoft-ServiceFabric-Actors",
"scheduledTransferKeywordFilter": "1",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableActorEventTable"
}
},
{
"provider": "Microsoft-ServiceFabric-Services",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableServiceEventTable"
}
}
],
"EtwManifestProviderConfiguration": [
{
"provider": "cbd93bc2-71e5-4566-b3a7-595d8eeca6e8",
"scheduledTransferLogLevelFilter": "Information",
"scheduledTransferKeywordFilter": "4611686018427387904",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricSystemEventTable"
}
}
]
}
}
},
"StorageAccount": "[variables('applicationDiagnosticsStorageAccountName')]"
},
"typeHandlerVersion": "1.5"
}
}