MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Datadog Tutorials: Tag Specifications

In a Datadog Agent log collection config, the tags field adds key:value tags to every log line the Agent collects from a source. You can then filter, group and control access to those logs in Datadog. This page explains the examples above, corrects two problems in them, and covers how to verify tags and which tagging conventions to follow.

Tag Specification for Log Collection


logs:
  - type: file
    path: /var/log/nginx/access.log
    tags: raju:ramu
    source: nginx

logs:
  - type: file
    path: /var/log/nginx/access.log
    env: raj
    tags: raju:ramu, env:prod, app:web
    source: nginxCode language: JavaScript (javascript)


What the tags field does in log collection

Each item under logs: in an integration config describes one log source. The Agent attaches every tag in tags to each log it ships from that source. Tags let you filter in Log Explorer (for example env:prod app:web), split queries and dashboards, build log-based metrics and monitors, and limit who can see which logs.

Tags work alongside a few reserved fields. source selects the processing pipeline that parses the logs (nginx enables the built-in Nginx pipeline). service links the logs to APM and to the Service Catalog. The Agent also adds host-level tags, such as host and any global tags set in datadog.yaml.

Corrected configuration

The second example above has two problems. The file declares logs: twice, and it uses env: raj as if env were a log setting. Duplicate top-level keys are invalid YAML. Depending on the parser, the Agent either rejects the file or quietly keeps only the last block. env is not a valid parameter for a log source, so the Agent ignores it. Set the environment as a tag instead. Here is a single valid file:

# /etc/datadog-agent/conf.d/nginx.d/conf.yaml
logs:
  - type: file
    path: /var/log/nginx/access.log
    service: web
    source: nginx
    tags:
      - env:prod
      - app:web
      - team:platform

  - type: file
    path: /var/log/nginx/error.log
    service: web
    source: nginx
    tags:
      - env:prod
      - app:webCode language: PHP (php)
  • One logs: key holds a list. Add more sources as more - type: file items under that key.
  • tags is written as a YAML list. The inline form tags: ["env:prod", "app:web"] is equivalent. Both are clearer than a single comma-separated string.
  • service is set explicitly. If you leave it out, logs may show up under a generic or missing service name.
  • Placeholder tags such as raju:ramu from the example above work, but use meaningful keys like team, app or owner in real configs.

Note: Use the same env value everywhere (Agent, APM, metrics). A tag like env:prod on logs and env:production on traces breaks correlation between the two.

Prerequisites and applying the change

  1. Turn on log collection in /etc/datadog-agent/datadog.yaml by setting logs_enabled: true. It is off by default.
  2. Put the config above in /etc/datadog-agent/conf.d/nginx.d/conf.yaml. If the Nginx integration is already set up for metrics, add the logs: block to that same file.
  3. Make sure the dd-agent user can read the log files. On Debian and Ubuntu, Nginx logs usually belong to the adm group: sudo usermod -aG adm dd-agent.
  4. Restart the Agent: sudo systemctl restart datadog-agent.
  5. Generate some traffic, for example curl -s http://localhost/ > /dev/null, then check the Agent status.

Verifying tags

sudo datadog-agent configcheck     # confirms the nginx config loaded without errors
sudo datadog-agent status          # see the "Logs Agent" section
sudo datadog-agent stream-logs     # live view of logs being processed (recent Agent versions)Code language: PHP (php)

In the status output, the Logs Agent section lists each source with its path, a status of OK, and bytes read. A permission error or a wrong path also appears here. In Datadog, open Log Explorer and search service:web env:prod. Click a log line to see its tags in the side panel.

Note: In Log Explorer, tags are searched without a prefix (env:prod), while attributes parsed from the log body use @ (@http.status_code:500). If a tag search returns nothing, check whether the value was parsed as an attribute instead.

Where else tags can be set

LevelHowApplies to
Log sourcetags: under a logs: itemLogs from that source only
Agent (global)tags: list and env: in datadog.yaml, or the DD_TAGS / DD_ENV environment variablesAll metrics, traces and logs from that host
ContainerAutodiscovery labels or annotations, such as com.datadoghq.ad.logs, plus unified service tagging labels for env, service and versionLogs from that container
PipelineProcessors in Logs > Pipelines (remappers, category processors)Logs after ingestion

Global Agent tags look like this in datadog.yaml. Tags from all levels are combined on each log:

env: prod
tags:
  - team:platform
  - region:ap-south-1Code language: CSS (css)

Common errors

SymptomLikely causeFix
No logs in Datadog at alllogs_enabled is not trueSet it in datadog.yaml and restart the Agent
Status shows a permission denied errordd-agent cannot read the fileAdd dd-agent to the owning group, or adjust file permissions
Only one source is collectedDuplicate logs: keys in one fileMerge them into one logs: list
env tag missingUsed env: as a log parameterMove it into tags: or set env globally
Config not loadedYAML indentation or tab charactersRun datadog-agent configcheck and use spaces only

Tagging best practices

  • Always use the key:value form. A bare tag without a key is hard to group by.
  • Keep tags lowercase and consistent. Agree on a small set of keys, such as env, service, version, team and app, and document them.
  • Use the reserved env, service and version tags (unified service tagging) so logs, traces and metrics link together.
  • Never put high-cardinality or sensitive values such as user IDs, request IDs, emails or tokens in tags. Leave them in the log body as attributes, and scrub secrets.
  • Set host-wide tags once at the Agent level rather than repeating them in every log source.

Frequently asked questions

How do I add multiple tags to a Datadog log source?

List them under tags: as YAML list items, for example - env:prod and - app:web, or inline as tags: ["env:prod", "app:web"]. Every log collected from that source gets all of the listed tags.

Can I set env directly on a log source in the Datadog Agent?

No. env is not a valid log source parameter, so the Agent ignores it. Add env:prod to the source's tags, or set env globally in datadog.yaml or with DD_ENV.

Why are my log tags not showing in Datadog?

Common causes are logs_enabled not set to true, a YAML error that stops the config from loading, or duplicate logs: keys. Run datadog-agent configcheck and datadog-agent status, then restart the Agent after fixing the file.

Do Agent global tags apply to logs?

Yes. Tags set with tags: in datadog.yaml or with DD_TAGS are added to logs from that host, along with any tags defined on the individual log source.

What is the difference between source and service in a log config?

source names the technology that produced the log and picks the matching processing pipeline, such as nginx. service names your application and links the logs to APM traces and the Service Catalog.

Related tutorials

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Datadog Troubleshooting Master Guide

It covers: Datadog Agent, Kubernetes Agent, Cluster Agent, integrations, logs, APM/traces, custom metrics, DogStatsD, OpenTelemetry, API keys, Terraform, monitors, SLOs, RUM, Synthetics, cloud integrations, cost, permissions, and…

Read More

Datadog FAQ / Interview Questions and Answers โ€” 50 Questions

Below is a Datadog theoretical / approach / capability FAQ set โ€” not MCQ style. These are the kinds of questions that usually come in interviews, internal…

Read More

What is Datadog: Observability, Monitoring, SIEM, AIOps, Security, and DevOps Platform

Datadog is a SaaS-based observability, monitoring, security, and service-management platform used by DevOps, SRE, platform, application, security, and business teams to understand the health, performance, reliability, cost,…

Read More

What is Datadog and use cases of Datadog?

What is Datadog? Datadog is a cloud-based monitoring and analytics platform that provides full-stack observability for dynamic and cloud-native environments. It allows organizations to collect, correlate, and…

Read More

Datadog Tutorials: Log Collection & configuration using Datadog Agent

How to enable Log collection in Datadog? To enable log collection with an Agent running on your host, change logs_enabled: false to logs_enabled: true in the Agentโ€™s…

Read More

Datadog Log: Setup Apache Log Analsys

Step 1 – Setup a Apache and start it Step 2 – Enable Log Monitoring in Datadog agent Prerequisite Step 3 – Modify conf.yaml of apache with…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Jason Mitchell
Jason Mitchell
3 months ago

An additional point worth covering is the long-term governance of tags in large environments. Tagging becomes significantly more valuable when every team follows the same naming conventions and classification rules. A standardized approach makes it easier to filter metrics, troubleshoot issues, assign ownership, and generate meaningful reports, while preventing the confusion that often results from inconsistent or duplicate tags.

1
0
Would love your thoughts, please comment.x
()
x