惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
aimingoo的专栏
aimingoo的专栏
B
Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
阮一峰的网络日志
阮一峰的网络日志
Engineering at Meta
Engineering at Meta
IT之家
IT之家
V
Visual Studio Blog
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
A
About on SuperTechFans
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
N
News and Events Feed by Topic
A
Arctic Wolf
WordPress大学
WordPress大学
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
F
Fortinet All Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Y
Y Combinator Blog
T
Threat Research - Cisco Blogs
Latest news
Latest news
Simon Willison's Weblog
Simon Willison's Weblog
Cyberwarzone
Cyberwarzone
S
Schneier on Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
Lohrmann on Cybersecurity
Stack Overflow Blog
Stack Overflow Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy International News Feed
J
Java Code Geeks
Spread Privacy
Spread Privacy
宝玉的分享
宝玉的分享
I
Intezer
L
LangChain Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
G
GRAHAM CLULEY
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
News and Events Feed by Topic
AWS News Blog
AWS News Blog
Attack and Defense Labs
Attack and Defense Labs
Security Archives - TechRepublic
Security Archives - TechRepublic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

Datadog | The Monitor blog

Introducing our open source AI-native SAST Instrument and monitor Boomi integration flows with OpenTelemetry and Datadog Not all index scans are equal: How we cut query latency by over 99% Platform engineering metrics: What to measure and what to ignore Integrate Recorded Future threat intelligence with Datadog Cloud SIEM CI/CD security: threat modeling using a MITRE-style threat matrix CI/CD security: How to secure your GitHub ecosystem Ingress NGINX is EOL: A practical guide for migrating to Kubernetes Gateway API Operating agentic AI with Amazon Bedrock AgentCore and Datadog LLM Observability: Lessons from NTT DATA Introducing the Datadog Code Security MCP Capture and analyze custom heatmaps in Session Replay Understand session replays faster with AI summaries and smart chapters Monitor ClickHouse query performance with Datadog Database Monitoring How we designed empathetic alert sounds for on-call engineers Search and act across Datadog to resolve issues faster with Bits Assistant Measure the business impact of every product change with Datadog Experiments Analyzing round trip query latency Configuring JavaScript caches for better performance Introducing Bits AI Dev Agent for Code Security Datadog achieves ISO 42001 certification for responsible AI Monitor Nutanix clusters, hosts, and VMs with Datadog Monitor Juniper Mist in Datadog A new Host Map for modern infrastructure Annotate traces to improve LLM quality with Datadog LLM Observability What’s new in Cloud SIEM: AI-powered investigations, enhanced threat intelligence, and scalable security operations Explore Kubernetes with native OpenTelemetry data Monitor Oracle Fusion Cloud Applications with Datadog Announcing the Datadog Terraform provider v4.0.0 Scaling Kubernetes workloads on custom metrics How to design cloud environments for AI-powered threat analysis Monitor Aruba Central in Datadog How we centralize and remediate risks with Datadog Case Management Accelerate incident response with Datadog and ServiceNow Monitor your application and network load balancer logs Understanding Karpenter architecture for Kubernetes autoscaling Tools for collecting metrics and logs from Karpenter Monitor Karpenter with Datadog What your product data is actually saying Key metrics for monitoring Karpenter Securing Datadog’s platform in the AI age: The role of observability data Four ways engineering teams use the Datadog MCP Server to power AI agents Approaching your observability migration with the right mindset Meet the new Bits AI SRE: Deeper reasoning, twice as fast Key learnings from the 2026 State of DevSecOps study Use plain English to query your multi-cloud infrastructure in Resource Catalog Simplifying troubleshooting across the user journey with Datadog Synthetic Monitoring Protect your OCI resources with Datadog Cloud Security This Month in Datadog - February 2026 Amazon EC2 security: How misconfigured and public AMIs expand your cloud attack surface Enable end-to-end visibility into your Java apps with a single command Measure and improve mobile app startup performance with Datadog RUM Evaluating our AI Guard application to improve quality and control cost Identify untested code across every level of your codebase Make use of guardrail metrics and stop babysitting your releases Monitor Versa Networks SD-WAN performance in Datadog Improve performance and reliability with APM Recommendations Remediate transitive vulnerabilities faster with Datadog Software Composition Analysis Generate audit-ready vulnerability and compliance reports with Datadog Sheets Monitor Fortinet FortiManager performance in Datadog Improve test coverage across codebases with Datadog Code Coverage Move fast, don’t break things: Consistent testing standards at scale Enrich logs with ServiceNow CMDB context before routing to any SIEM or logging tool Monitor Lustre with Datadog Make faster, better product decisions with Datadog Product Analytics Surface and remediate runtime posture issues with Workload Protection Findings Protect agentic AI applications with Datadog AI Guard How to optimize JavaScript code with CSS Trace Google Pub/Sub workloads in Cloud Run with Datadog Detect human names in logs with ML in Sensitive Data Scanner How we cut our NLQ agent debugging time from hours to minutes with LLM Observability Debug PostgreSQL query latency faster with EXPLAIN ANALYZE in Datadog Database Monitoring Datadog acquires Propolis Unify and correlate frontend and backend data with retention filters Scale compliance across global frameworks with Datadog Cloud Security Monitor Arista VeloCloud SD-WAN performance with Datadog Building reliable dashboard agents with Datadog LLM Observability Simplify log collection and aggregation for MSSPs with Datadog Observability Pipelines Mitigation for Node.js denial-of-service vulnerability affecting Datadog APM Automate flaky test fixes with the Bits AI Dev Agent and Test Optimization How we built an AI SRE agent that investigates like a team of engineers Datadog integrations 2025 recap: Observability for AI, security, and hybrid cloud Design effective executive dashboards with Datadog Implement dbt data quality checks with dbt-expectations Bring faster visibility into AWS Lambda functions with remote instrumentation Troubleshoot faster with the GitLab Source Code integration in Datadog How Cambia Health Solutions saved $30,000 monthly with Cloud Cost Management and the Datadog Resource Catalog Normalize any logs for Cloud SIEM with Datadog's OCSF processor Optimizing Datadog at scale: Cost-efficient observability at Zendesk Detect, diagnose, and resolve network issues easily with CNM Network Health Connect engineering errors to user impact in early-stage products Cilium configuration for Kubernetes operations at scale Designing feedback loops for progressive delivery Ship features faster and safer with Datadog Feature Flags Choosing the right OpenTelemetry Collector distribution Route your monitor alerts with Datadog monitor notification rules Automate Cloud SIEM investigations with Bits AI Security Analyst Cloud threat detection: How to identify risky activity across control and data planes Collecting Kafka performance metrics Monitoring Kafka with Datadog Monitoring Kafka performance metrics
Monitoring Django performance with Datadog
2018-03-22 · via Datadog | The Monitor blog

Django is an open source Python-based web framework that dynamically renders web content based on the incoming HTTP request. Designed to follow the MVT design pattern and provide out-of-the-box functionality, the Django framework prioritizes rapid development and clean, reusable code. Django also puts an emphasis on versatility: the framework can support most web content formats, such as HTML and XML, and since Django is Python-based, it can run on all common server operating systems.

Deploying a Django application requires a few supporting technologies. A database stores application data. A web server listens for incoming HTTP requests and is responsible for sending responses back to clients, as well as serving static files and routing any other requests to the Web Server Gateway Interface (WSGI). A WSGI facilitates communication between the web server and the Python application. We will be using PostgreSQL for our database, NGINX as our web server, and Gunicorn as our WSGI in this guide.

This guide will cover how to monitor your Django application performance (along with PostgreSQL, NGINX, and Gunicorn) using Datadog so that you can collect metrics, logs, and request traces from the various parts of your application. Command snippets in this guide are provided for Linux hosts; if you are using a different operating system, some commands may differ from the ones presented.

Getting started with Datadog

To collect metrics, request traces, and logs from your application, you’ll need to install the latest version of the Datadog Agent on your application host. You can download and install the Agent with the following command, which will prompt you for your system root password:

DD_API_KEY=<API_KEY> DD_AGENT_MAJOR_VERSION=7 bash -c "$(curl -L https://raw.githubusercontent.com/DataDog/datadog-agent/master/cmd/agent/install_script.sh)"

If you have a Datadog account set up, you can find your API key here. If you haven’t tried Datadog yet, you can get started with a free trial.

Log collection, which we’ll cover below, requires version 6 of the Agent. If you’re using a previous version, run the following command to upgrade the Agent and carry over your pre-existing configuration files:

DD_API_KEY=<API_KEY> DD_AGENT_MAJOR_VERSION=7 bash -c "$(curl -L https://raw.githubusercontent.com/DataDog/datadog-agent/master/cmd/agent/install_script.sh)"

Configuring the Datadog Agent

Next we’ll ensure that the Agent is properly configured to collect logs and request traces. Open up the datadog.yaml configuration file in the Agent directory:

sudo vi /etc/datadog-agent/datadog.yaml

By default, APM request tracing is enabled on versions 5.13 and greater of the Datadog Agent. To enable APM tracing on older compatible versions (5.11 or greater), add the parameter apm_enabled: true to the configuration file.

To enable log collection (Agent version 6), set log_enabled: true in /etc/datadog-agent/datadog.yaml. Restart the Agent to reload the configuration file:

sudo service datadog-agent restart

Setting up Django performance monitoring

Using Datadog APM, you can trace requests across all the different services supporting your application. With our Django integration, requests, template renders, and database queries are all automatically traced. To set up the trace client for Python applications, install the ddtrace library in your application’s environment:

pip install ddtrace

Datadog APM traces a request to a Django application from end to end.
Monitor Django Performance, Services, and Traces
Datadog APM traces a request to a Django application from end to end.

After installing the ddtrace client, run the ddtrace-run wrapper with your Gunicorn command, keeping all the arguments intact:

ddtrace-run gunicorn [...] myapp.wsgi:application [...]

To enable the Django integration, add the following under the INSTALLED_APPS header in your application’s settings.py file:

INSTALLED_APPS = [

# your Django apps...

'ddtrace.contrib.django',

]

Restart Gunicorn to reload your settings configuration:

sudo service gunicorn restart

After sending a few requests to your web app, services should start showing up in the Datadog APM page under your app’s environment tag.

Keeping track of PostgreSQL

Datadog is now automatically recording services and request traces from your Django application. In this section, you’ll learn how to integrate Datadog with PostgreSQL directly, allowing you to visualize and alert on dozens of database-specific metrics, as well as any data contained in your Postgres logs.

PostgreSQL metrics

To prepare PostgreSQL for metric collection, start a psql session as a user with CREATEROLE privileges. In your session, run these commands to create a datadog user with access to pg_stat_database:

create user datadog with password '<PASSWORD>';

grant SELECT ON pg_stat_database to datadog;

To confirm that the new user has the right read access, run the following shell command:

psql -h localhost -U datadog postgres -c \ "select * from pg_stat_database LIMIT(1);" && echo -e "\e[0;32mPostgres connection - OK\e[0m" || \ || echo -e "\e[0;31mCannot connect to Postgres\e[0m"

If you see Postgres connection - OK, then you have successfully created the correct user.

To configure the Agent to collect PostgreSQL metrics, create a conf.yaml file from the provided template.

sudo cp /etc/datadog-agent/conf.d/postgres.d/conf.yaml.example /etc/datadog-agent/conf.d/postgres.d/conf.yaml

Add the following to your newly created file:

init_config:

instances:

- host: localhost

port: 5432

username: datadog

password: <PASSWORD>

Datadog’s built-in dashboard for PostgreSQL provides in-depth visibility into your databases out of the box.
Monitor Django Performance With Datadog’s Default PostgreSQL Screenboard
Datadog’s built-in dashboard for PostgreSQL provides in-depth visibility into your databases out of the box.

PostgreSQL logs

To set up PostgreSQL for log collection, edit the /etc/postgresql/<version>/main/postgresql.conf file and make sure the following parameters are set under the Error Reporting and Logging header:

logging_collector = on

log_directory = '/var/log/postgresql'

log_filename = 'pg.log'

log_statement = 'all'

log_line_prefix= '%m [%p] %d %a %u %h %c '

log_file_mode = 0644

Restart PostgreSQL to reload the configuration.

sudo service postgresql restart

If you restart PostgreSQL and the log file at /var/log/postgresql/pg.log isn’t showing up, or is empty, you may have to create the file yourself and give ownership of the /var/log/postgresql directory to user postgres.

sudo chown postgres /var/log/postgresql/

To configure the Datadog Agent to collect PostgreSQL logs, add the following lines to the end of /etc/datadog-agent/conf.d/postgres.d/config.yaml:

logs:

- type: file

path: /var/log/postgresql/pg.log

source: postgresql

sourcecategory: database

service: my_database

Restart the Datadog Agent to reload the configuration.

sudo service datadog-agent restart

You can check to see if your configuration is correct by running the following command:

sudo datadog-agent status

You should see output similar to the following:

Collector

=========

Running Checks

==============

postgres

--------

Total Runs: 5

Metrics: 29, Total Metrics: 145

Events: 0, Total Events: 0

Service Checks: 1, Total Service Checks: 5

[...]

Logs-agent

==========

postgres

--------

Type: file

Path: /var/log/postgresql/pg.log

Status: OK

Inputs: /var/log/postgresql/pg.log

Integrating NGINX with Datadog

In this section, you’ll learn how to collect NGINX metrics and logs with Datadog, giving you insights into the traffic coming in and out of your application, as well as the overall health of your web server.

NGINX metrics

The NGINX Agent Check retrieves metrics from the NGINX status page, which depends on the stub status module. If you don’t have the stub status module installed, you may need to reinstall or rebuild NGINX. Use the following command to check if your version of NGINX was compiled with the module:

nginx -V 2>&1| grep -o http_stub_status_module

If the stub status module is installed, the command will output http_stub_status_module.

To prepare NGINX for metrics reporting, create a status.conf file in /etc/nginx/conf.d and populate it with the following, replacing stub_status; with status; if you are using NGINX Plus:

server {

listen 81;

server_name localhost;

access_log off;

allow 127.0.0.1;

deny all;

location /nginx_status {

stub_status;

}

}

To configure the agent for NGINX metric collection, create a conf.yaml file from the provided example.

sudo cp /etc/datadog-agent/conf.d/nginx.d/conf.yaml.example /etc/datadog-agent/conf.d/nginx.d/conf.yaml

Add the following to your newly created file to start collecting NGINX metrics from the status page:

init_config:

instances:

- nginx_status_url: http://localhost:81/nginx_status/

NGINX logs

For collection of NGINX logs, uncomment the following lines in the same conf.yaml file:

logs:

- type: file

path: /var/log/nginx/access.log

service: my_web_app

source: nginx

sourcecategory: http_web_access

- type: file

path: /var/log/nginx/error.log

service: my_web_app

source: nginx

sourcecategory: http_web_access

Restart the Datadog Agent to reload the configuration.

sudo service datadog-agent restart

You can check to see if your configuration is correct by running the following command:

sudo datadog-agent status

Error-free NGINX sections should appear under both the Collector and Logs-agent headers.

An example of an NGINX log stream collected by Datadog.
Monitor Django Performance and NGINX logs with Datadog
An example of an NGINX log stream collected by Datadog.

Gathering Gunicorn metrics

This section will cover the collection of Gunicorn metrics using Datadog, giving you access to important information about the requests being handled by your application.

The Gunicorn Agent Check requires the setproctitle Python package to be installed in the Gunicorn application’s Python environment. To install the package, activate your app’s Python environment and run:

pip install setproctitle

To start collecting Gunicorn metrics, create a conf.yaml file from the provided example.

sudo cp /etc/datadog-agent/conf.d/gunicorn.d/conf.yaml.example /etc/datadog-agent/conf.d/gunicorn.d/conf.yaml

Add the following to your newly created conf.yaml file, where my_web_app is the name of your application (you can check your application’s name using the command ps -ef | grep 'gunicorn'):

init_config:

instances:

- proc_name: my_web_app

Restart the Datadog Agent to reload the configuration.

sudo service datadog-agent restart

Datadog’s Gunicorn integration collects information on the number and status of worker processes. To collect metrics about request rates, status codes, request durations, and more, you can configure Gunicorn to send metrics to the Datadog Agent using the StatsD protocol. Simply append --statsd-host=localhost:8125 to your Gunicorn command and restart Gunicorn to see your changes take effect.

sudo service gunicorn restart

Running sudo datadog-agent status should give output similar to the following:

[...]

gunicorn

--------

Total Runs: 1

Metrics: 2, Total Metrics: 2

Events: 0, Total Events: 0

Service Checks: 1, Total Service Checks: 1

[...]

=========

DogStatsD

=========

Checks Metric Sample: 882

Event: 1

Events Flushed: 1

Number Of Flushes: 4

Series Flushed: 403

Service Check: 64

Service Checks Flushed: 52

You should also see metrics start to show up on Datadog’s out-of-the-box Gunicorn dashboard.

Datadog’s out-of-the-box Gunicorn dashboard
Monitor Django Performance With Datadog’s Default Gunicorn Dashboard
Datadog’s out-of-the-box Gunicorn dashboard

Custom Python metrics and events

If you’d like to collect your own custom metrics and events, install Datadog’s Python library in your application’s environment:

pip install datadog

Once you’ve installed the library, you gain access to the Datadog HTTP API, DogStatsD, and ThreadStats Python modules. With these tools, you can instrument your code to send custom metrics and events to the Datadog Agent.

Django-specific dashboards

Creating a custom dashboard allows you to monitor your Django application at a glance. If you aren’t sure what to put on your dashboard, see the out-of-the-box dashboards for Gunicorn, NGINX, or Postgres.

To import the example dashboard into your Datadog app, run the following curl command:

curl -X POST -H "Content-type: application/json" \

-d '<CONTENTS_OF_EXAMPLE_JSON_GIST>' \

"https://app.datadoghq.com/api/v1/screen?api_key=${<YOUR_DATADOG_API_KEY>}&application_key=${<YOUR_DATADOG_APP_KEY>}"

An example dashboard for Django performance monitoring
Monitor Django Performance with custom dashboards
An example dashboard for Django performance monitoring

Diving into Django application performance

After configuring Datadog to monitor your Django application, you’ll have access to data from across your stack for performance monitoring and rapid troubleshooting. Let’s look at an example scenario: you’ve just received a Datadog alert notifying you that Gunicorn is reporting a large number of 5xx responses.

Monitor Django Performance and Alerts with Datadog

You can dive right into a dashboard graph for some further context. It’s clear that some event—in this case, a code change, which is overlaid on the graph as a pink bar—has caused the number of 5xx responses to spike.

A code change event, depicted by a pink vertical line, causes an increase in 5xx status codes returned.
Monitor Django Performance, Metrics, and Events
A code change event, depicted by a pink vertical line, causes an increase in 5xx status codes returned.

To gather more information on the nature of the errors, you can pivot to Datadog APM, drilling down to all the traces returning 5xx codes in the relevant timeframe. It seems that the request error is the result of a faulty PostgreSQL query. Also note that the error is being caused by a POST request to the /create/ URL path.

A POST request triggers a faulty PostgreSQL query, resulting in a 5xx error being returned.
Monitor Django Performance and Traces
A POST request triggers a faulty PostgreSQL query, resulting in a 5xx error being returned.

To find the issue with the PostgreSQL query, you can pull up the error logs for the query. The logs reveal the source of the problem: our application is attempting to insert a long string—longer than the limit of 3,000 characters.

Monitor Django Performance and Logs

Thanks to our comprehensive monitoring coverage, we can smoothly pivot between data from logs, metrics, and request traces to determine that the most recent code change is causing some POST requests to the /create/ URL path to attempt PostgreSQL string inserts that exceed the character limit.

Get started today

If you’re already using Datadog, check out our documentation for further information on how to monitor Django performance for your applications and their accompanying technologies. And if you don’t yet have a Datadog account, here’s a free trial to get you started.