4
votes

I'm running web apps as Docker containers in Azure App Service. I'd like to add Datadog agent to each container to, e.g., read the log files in the background and post them to Datadog log management. This is what I have tried:

1) Installing Datadog agent as extension as described in this post. This option does not seem to be available for App Service apps, only on VMs.

2) Using multi-container apps as described in this post. However, we have not found a simple way to integrate this with Azure DevOps release pipelines. I guess it might be possible to create a custom deployment task wrapping Azure CLI commands?

3) Including Datadog agent into our Dockerfiles by following how Datadog Dockerfiles are built. The process seems quite complicated and add lots of extra dependencies to our Dockerfile. We'd also not like to inherit our Dockerfiles from Datadog Dockerfile with FROM datadog/agent.

I'd assume this must be a pretty standard problem for Azure+Datadog users. Any ideas what's the cleanest option?

5

5 Answers

1
votes

I doubt the Datadog agent will ever work on App Services web app as you do not have access to the running host, it was designed for VMs. Have you tried this https://www.datadoghq.com/blog/azure-monitoring-enhancements/ ? They say they support AppServices

1
votes

Logs from App Services can also be sent to Blob storage and forwarded from there via an Azure Function. Unlike traces and custom metrics from App Services, this does not require a VM running the agent. Docs and code for the Function are available here:

https://github.com/DataDog/datadog-serverless-functions/tree/master/azure/blobs_logs_monitoring

1
votes

If you want to use DataDog for logging from Azure Function of App Service you can use Serilog and DataDog Sink to the log files:

        services
            .AddLogging(loggingBuilder =>
                loggingBuilder.AddSerilog(
                    new LoggerConfiguration()
                        .WriteTo.DatadogLogs(
                            apiKey: "REPLACE - DataDog API Key",
                            host: Environment.MachineName,
                            source: "REPLACE - Log-Source",
                            service: GetServiceName(),
                            configuration: new DatadogConfiguration(),
                            logLevel: LogEventLevel.Infomation
                        )
                        .CreateLogger())
            );

Full source code and required NuGet packages are here:

0
votes

To respond to your comment on wanting custom metrics, this is still possible without the agent at the same location. After installing the nuget package of datadog called statsdclient you can then configure it to send the custom metrics to an agent located elsewhere. Example below:

using StatsdClient;

var dogstatsdConfig = new StatsdConfig
{
    StatsdServerName = "127.0.0.1", // Optional if DD_AGENT_HOST environment variable set
    StatsdPort = 8125, // Optional; If not present takes the DD_DOGSTATSD_PORT environment variable value, else default is 8125
    Prefix = "myTestApp", // Optional; by default no prefix will be prepended
    ConstantTags = new string[1] { "myTag:myTestAppje" } // Optional
};

StatsdClient.DogStatsd.Configure(dogstatsdConfig);
StatsdClient.DogStatsd.Increment("fakeVisitorCountByTwo", 2); //Custom metric itself
0
votes

I have written a app service extension for sending Datadog APM metrics with .NET core and provided instructions for how to set it up here: https://github.com/payscale/datadog-app-service-extension

Let me know if you have any questions or if this doesn't apply to your situation.