Tagging
Use tags to organize, filter, and manage your targets effectively.
What Are Tags?
Section titled “What Are Tags?”Tags are key-value pairs attached to targets for organization and filtering:
target: web-prod-01tags: role: web region: us-east-1 tier: frontend team: platformTag Structure
Section titled “Tag Structure”| Component | Description | Example |
|---|---|---|
| Key | Category name | role, region, team |
| Value | Specific value | web, us-east-1, platform |
Naming Conventions
Section titled “Naming Conventions”| Rule | Good | Bad |
|---|---|---|
| Lowercase keys | role | Role, ROLE |
| Alphanumeric | team_name | team-name! |
| Descriptive | deployment_group | dg |
| No spaces | data_center | data center |
Adding Tags
Section titled “Adding Tags”Single Target
Section titled “Single Target”┌─────────────────────────────────────────────────────────────┐│ Target: web-prod-01 │├─────────────────────────────────────────────────────────────┤│ ││ Tags: ││ ┌───────────────────────────────────────────────────────┐ ││ │ role │ web │ [×] │ ││ │ region │ us-east-1 │ [×] │ ││ │ tier │ frontend │ [×] │ ││ └───────────────────────────────────────────────────────┘ ││ ││ Add Tag: ││ Key: [team_____________] Value: [platform_________] ││ [Add Tag] ││ │└─────────────────────────────────────────────────────────────┘Via REST API
Section titled “Via REST API”Tags are created once, then attached to targets by tag ID. Tag management is
performed in Lens or via the REST API (there is no mantisctl tag subcommand).
# Attach one or more existing tags to a targetcurl -X POST "$MANTIS_URL/api/v1/targets/<target-id>/tags" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"tag_ids": ["<role-web-tag-id>", "<region-tag-id>"]}'Removing Tags
Section titled “Removing Tags”From UI
Section titled “From UI”Click the [×] next to any tag to remove it.
Via REST API
Section titled “Via REST API”# Detach one or more tags from a targetcurl -X DELETE "$MANTIS_URL/api/v1/targets/<target-id>/tags" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"tag_ids": ["<role-web-tag-id>"]}'Standard Tag Taxonomy
Section titled “Standard Tag Taxonomy”Recommended Tags
Section titled “Recommended Tags”| Tag Key | Purpose | Example Values |
|---|---|---|
role | Server function | web, api, worker, db, cache |
environment | Deploy environment | development, staging, production |
region | Geographic location | us-east-1, eu-west-1, ap-south-1 |
tier | Application tier | frontend, backend, data |
team | Owning team | platform, payments, auth |
service | Service name | user-api, order-service |
cost_center | Billing allocation | engineering, operations |
Example Tag Sets
Section titled “Example Tag Sets”Web Server:
role: webtier: frontendregion: us-east-1team: platformDatabase Server:
role: databasetier: datadb_type: postgresqlreplication: primaryWorker Node:
role: workerqueue: high-priorityservice: order-processorFiltering by Tags
Section titled “Filtering by Tags”Via REST API
Section titled “Via REST API”GET /api/v1/targets returns each target with its tags, so you can filter
client-side (the list endpoint has no tag query parameter). Tag filtering is not available in the Lens UI; use the jq client-side approach below.
# List targets tagged role=webcurl "$MANTIS_URL/api/v1/targets" -H "Authorization: Bearer $TOKEN" | \ jq '.data[] | select(.tags[] | .key == "role" and .value == "web")'Tags in Deployments
Section titled “Tags in Deployments”Target Selection by Tag
Section titled “Target Selection by Tag”Deploy to targets matching tag criteria with --target-tag (repeatable):
mantisctl deployment create --solution-id customer-portal \ --source-version 1.3.0 \ --target-tag role=web \ --target-tag region=us-east-1Tag-Based Rollout Strategy
Section titled “Tag-Based Rollout Strategy”Staged Deployment by Tag
Section titled “Staged Deployment by Tag”Phase 1: Deploy to tag:canary=truePhase 2: Deploy to tag:region=us-east-1Phase 3: Deploy to tag:region=us-west-2Phase 4: Deploy to tag:region=eu-west-1Tag-Based Organization
Section titled “Tag-Based Organization”By Team
Section titled “By Team”Tags: team=platform, team=payments, team=auth
By Environment
Section titled “By Environment”Tags: environment=production, environment=staging, environment=development
By Service
Section titled “By Service”service=user-api: - user-api-01 - user-api-02
service=order-service: - order-svc-01 - order-svc-02
service=payment-gateway: - payment-01 - payment-02Tag Management Best Practices
Section titled “Tag Management Best Practices”1. Establish a Taxonomy
Section titled “1. Establish a Taxonomy”Define standard tags before deployment:
## Required Tags
All targets MUST have:
- role: Server function (web, api, worker, db)- environment: Environment name (from Mantis environments)- team: Owning team
## Optional Tags
- region: Geographic region- service: Service/application name- cost_center: For billing- maintenance_window: Preferred maintenance time2. Use Consistent Values
Section titled “2. Use Consistent Values”| Instead of | Use |
|---|---|
prod, production, prd | production |
US-East-1, us_east_1 | us-east-1 |
WebServer, web-server | web |
3. Avoid Over-Tagging
Section titled “3. Avoid Over-Tagging”Keep tags meaningful:
| Good | Avoid |
|---|---|
role=web | is_web_server=true |
team=platform | managed_by_platform_team=yes |
tier=frontend | tier=frontend_presentation_layer |
4. Document Tag Usage
Section titled “4. Document Tag Usage”Maintain documentation of tag meanings:
| Tag | Values | Description |
|---|---|---|
role | web, api, worker, db | Server’s primary function |
region | us-east-1, us-west-2, etc. | AWS region location |
tier | frontend, backend, data | Application architecture tier |
5. Audit Tags Regularly
Section titled “5. Audit Tags Regularly”Review tags periodically:
# List all unique tag keys across targetscurl -s "$MANTIS_URL/api/v1/targets" -H "Authorization: Bearer $TOKEN" | \ jq -r '.data[].tags[].key' | sort | uniq
# Find targets missing a required tag key (e.g. role)curl -s "$MANTIS_URL/api/v1/targets" -H "Authorization: Bearer $TOKEN" | \ jq '.data[] | select([.tags[].key] | index("role") | not) | .name'
# Find targets carrying a deprecated tagcurl -s "$MANTIS_URL/api/v1/targets" -H "Authorization: Bearer $TOKEN" | \ jq '.data[] | select([.tags[].key] | index("deprecated")) | .name'Troubleshooting
Section titled “Troubleshooting”Tags Not Saving
Section titled “Tags Not Saving”Cause: Invalid characters in key or value
Solution: Use lowercase alphanumeric characters and underscores only
Filter Returns No Results
Section titled “Filter Returns No Results”Cause: Tag values don’t match exactly
Solution: Check for typos, case sensitivity, extra spaces
Next Steps
Section titled “Next Steps”- Managing Targets - Target management
- Health Status - Monitor target health
- Overview - Return to targets overview
