Custom Tagging

Custom tags allow you to attach metadata to captured connections based on process environment variables, container labels, or Kubernetes labels and annotations. This is especially useful for:

  • Multi-tenant environments: Tag traffic by team, customer, or tenant

  • Environment identification: Distinguish between production, staging, and development traffic

  • Cost allocation: Track usage by department, project, or business unit

  • Service organization: Identify traffic by service name, version, or component

  • Qplane filtering: Filter and organize captured traffic in the Qplane UI by custom dimensions

Custom tags appear in the tags object of Connection events (event store) alongside default tags like bin, host, ip, protocol, and strategy. Tags are connection-level metadata and do not appear in HTTP transaction objects (object store).

Configuration

Custom tags are defined in the tags section of your qtap configuration:

tags:
  - key: team
    source: env
    location: TEAM
  - key: service
    source: container.label
    location: service
  - key: environment
    source: k8s.label
    location: env

Field Reference

Field
Type
Required
Description

key

string

Yes

The name of the tag as it will appear in the tags object

source

string

Yes

Where to extract the tag value from (see Tag Sources)

location

string

Yes

The specific environment variable name, label key, or annotation key to extract

Tag Sources

Qtap supports extracting tag values from multiple sources:

Source
Description
Example

env

Environment variable from the monitored process

source: env location: APP_NAME

container.label

Docker container label

source: container.label location: service

k8s.label

Kubernetes pod label

source: k8s.label location: team

k8s.annotation

Kubernetes pod annotation

source: k8s.annotation location: version

Examples

Environment Variables

Extract tags from environment variables set on your applications:

When you run your application with environment variables:

The captured connections will include:

Container Labels

Extract tags from Docker container labels:

Run containers with labels:

Tags in captured connections:

Kubernetes Labels

Extract tags from Kubernetes pod labels:

Pod manifest with labels:

Tags in captured connections:

Kubernetes Annotations

Extract tags from Kubernetes pod annotations:

Pod manifest with annotations:

Combining Tag Sources

You can combine tags from multiple sources:

All tags from different sources are merged together in the Connection event.

Static Tags (CLI Flag)

In addition to dynamic tags extracted from the YAML configuration, you can add static tags to all connections using the --tags CLI flag:

Format: The --tags flag uses key:value pairs separated by commas (not key=value).

Static tags are useful for:

  • Identifying the qtap instance or node

  • Tagging by region, datacenter, or availability zone

  • Marking deployment environment at the infrastructure level

Static tags and dynamic tags (from YAML) are merged together:

Tag Behavior

Missing Values

If a tag's source value doesn't exist, the tag is simply omitted from the output (no errors are logged):

If the TEAM environment variable is not set on the process, the team tag won't appear in the Connection event.

Tag Merging

When the same tag key is defined in multiple sources, all values are merged into an array:

Example with environment variable and CLI flag:

Result:

This applies to all tag sources:

  • YAML-defined tags (env, container.label, k8s.label, k8s.annotation)

  • CLI --tags flag

  • Default qtap tags (bin, host, ip, protocol, strategy)

Even default tags can be extended:

Result:

All tag values from all sources are preserved in the array.

Use Cases

Multi-Tenant SaaS Platform

Tag traffic by tenant and tier for cost allocation:

Run application:

Microservices Environment

Identify traffic by service, version, and team:

Cost Tracking by Department

Tag traffic for cost allocation across departments:

Run application:

Environment-Specific Tagging

Distinguish between production, staging, and development:

Run in production:

Run in staging:

Viewing Tags in Qplane

When qtap is connected to Qplane, custom tags appear in the Qplane UI and can be used for:

  • Filtering connections: Filter by team, environment, service, etc.

  • Grouping traffic: Group connections by custom dimensions

  • Creating dashboards: Visualize traffic patterns by custom tags

  • Setting alerts: Alert on traffic patterns for specific tags

Custom tags make it easy to organize and filter large volumes of captured traffic across multiple teams, services, and environments.

Best Practices

Security Considerations

Use Static Tags for Infrastructure

Use the --tags CLI flag for infrastructure-level tags that don't change per process:

Use YAML tags for application-level tags that vary per process:

Complete Example

Here's a complete configuration combining multiple tag sources:

Start qtap with static infrastructure tags:

Run your application with environment variables:

The resulting Connection events will include all tags:

Last updated