I have a DotNet Core docker container running on AKS that needs to process messages from a queue and send telemetry to Application Insights or Log Analytics. I have a ASP.NetCore app that works fine, but I cannot see any logs from my console app.
This is how I start the application:
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddEnvironmentVariables();
})
.ConfigureLogging((hostBuilderContext, loggingBuilder) =>
{
loggingBuilder.AddConsole(consoleLoggerOptions => consoleLoggerOptions.TimestampFormat = "[HH:mm:ss]");
})
.ConfigureServices(services =>
{
services.AddHostedService<RunsQueueProcessor>();
services.AddApplicationInsightsTelemetryWorkerService();
services.AddApplicationInsightsKubernetesEnricher();
});
And this is my applicationsettings.json
{
"Logging": {
"IncludeScopes": true,
"LogLevel": {
"Default": "Information",
"System": "Information",
"Microsoft": "Information"
}
},
"ApplicationInsights": {
"InstrumentationKey": ".....",
"LogLevel": {
"Default": "Information"
}
},
"ServiceBus": {
"ConnectionString": "..."
},
"ConnectionStrings": {
"DatabaseContext": "...",
}
What is the right way of adding monitoring to these type of applications?
[EDIT]
This is my deployment yaml file. I am running it from an Azure DevOps pipeline
apiVersion: apps/v1
kind: Deployment
metadata:
name: <project>-deployment
spec:
replicas: 1
selector:
matchLabels:
run: <project>-worker
template:
metadata:
labels:
run: <project>-worker
spec:
containers:
- name: <container>
image: <acr>.azurecr.io/<container>:{tag}
This is my deployment task. I am doing -f and passing the previous file
- task: Kubernetes@1
inputs:
connectionType: 'Azure Resource Manager'
azureSubscriptionEndpoint: '<>'
azureResourceGroup: '<azure-rg>'
kubernetesCluster: '<aks-cluster>'
useClusterAdmin: true
command: 'apply'
arguments: '-f src/<...>/deployment.yaml'
secretType: 'dockerRegistry'
containerRegistryType: 'Azure Container Registry'
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…