nthlayer identity¶
Service identity resolution and management for consistent naming across systems.
Services often have different names across systems (Kubernetes, Prometheus, PagerDuty, etc.). This command helps resolve and normalize service identities.
Usage¶
Subcommands¶
resolve¶
Resolve a service name to its canonical identity.
list¶
List all known service identities.
normalize¶
Show how a service name gets normalized.
add-mapping¶
Add an explicit identity mapping.
Examples¶
Resolve Service Identity¶
Output:
╭──────────────────────────────────────────────────────────────────────────────╮
│ Identity Resolution: checkout-svc │
╰──────────────────────────────────────────────────────────────────────────────╯
Canonical Name: checkout-service
Known Aliases:
• checkout-svc (kubernetes deployment)
• checkout_service (prometheus metrics)
• checkout-service-prod (pagerduty)
• CheckoutService (backstage)
Resolution Path:
Input: checkout-svc
Normalized: checkout-svc
Matched: checkout-service (similarity: 0.92)
Canonical: checkout-service
List All Identities¶
Output:
Known Service Identities:
┌─────────────────────┬────────────────────────────────────────────────────────┐
│ Canonical Name │ Aliases │
├─────────────────────┼────────────────────────────────────────────────────────┤
│ checkout-service │ checkout-svc, checkout_service, CheckoutService │
│ payment-api │ payment-service, payments-api, PaymentAPI │
│ user-service │ user-svc, users, UserService │
│ order-service │ orders, order-api, OrderService │
└─────────────────────┴────────────────────────────────────────────────────────┘
Show Normalization¶
Output:
Normalization Steps:
1. Input: "Payment-API_v2"
2. Lowercase: "payment-api_v2"
3. Normalize: "payment-api-v2"
4. Strip: "payment-api"
5. Canonical: "payment-api"
Add Custom Mapping¶
Output:
Normalization Rules¶
Service names are normalized using these rules:
| Rule | Example |
|---|---|
| Lowercase | PaymentAPI → paymentapi |
| Replace underscores | payment_api → payment-api |
| Strip version suffixes | service-v2 → service |
| Strip environment suffixes | service-prod → service |
| Strip common suffixes | payment-service → payment (optional) |
Identity Sources¶
Identities are discovered from:
- service.yaml - Explicit
service.namedeclaration - Backstage - Catalog entity names
- Kubernetes - Deployment/Service names
- Prometheus - Metric label values
- PagerDuty - Service names
Configuration¶
Custom Mappings File¶
Create .nthlayer/identity-mappings.yaml:
mappings:
# Explicit aliases
legacy-checkout: checkout-service
old-payment-system: payment-api
# Regex patterns
patterns:
- match: "^(.+)-prod$"
canonical: "$1"
- match: "^(.+)_service$"
canonical: "$1-service"
Environment-Specific Names¶
# service.yaml
service:
name: checkout-service
identity:
kubernetes: checkout-svc
prometheus: checkout_service
pagerduty: Checkout Service
Use Cases¶
Cross-System Correlation¶
# Find all references to a service across systems
canonical=$(nthlayer identity resolve "$ALERT_SERVICE" | grep "Canonical" | awk '{print $3}')
echo "Looking for $canonical in all systems..."
Metric Queries¶
# Get the Prometheus-style name for queries
prom_name=$(nthlayer identity normalize "$SERVICE" --style prometheus)
curl "$PROMETHEUS_URL/api/v1/query?query=up{service=\"$prom_name\"}"
Service Discovery¶
# Resolve service name from Kubernetes event
k8s_name=$(kubectl get events -o json | jq -r '.items[0].involvedObject.name')
canonical=$(nthlayer identity resolve "$k8s_name")
See Also¶
- nthlayer ownership - Find service owners
- nthlayer deps - View service dependencies
- Service YAML Schema