Monitoring & Observability
Set up Prometheus metrics, Grafana dashboards, and structured logging for Lynq. Includes metrics catalog, events reference, and alerting overview.
Lynq exposes 15 Prometheus metrics at :8443/metrics, emits structured Kubernetes events per reconciliation, and ships a pre-built Grafana dashboard.
Setup
Prometheus
Enable ServiceMonitor (requires Prometheus Operator): uncomment the prometheus section in config/default/kustomization.yaml:
- ../prometheus # uncomment this lineThen redeploy:
kubectl apply -k config/defaultManual scrape config:
# prometheus.yml
scrape_configs:
- job_name: lynq
kubernetes_sd_configs:
- role: pod
namespaces:
names: [lynq-system]
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_control_plane]
action: keep
regex: controller-manager
- source_labels: [__meta_kubernetes_pod_container_port_name]
action: keep
regex: httpsTest the endpoint:
kubectl port-forward -n lynq-system deployment/lynq-controller-manager 8443:8443
curl -k https://localhost:8443/metrics | grep lynqnode_Troubleshoot no metrics data:
# Check flag is set
kubectl get deployment -n lynq-system lynq-controller-manager -o yaml | grep metrics-bind-address
# Should show: --metrics-bind-address=:8443 (not "0")
# Check service exists
kubectl get svc -n lynq-system lynq-controller-manager-metrics-service
# Check ServiceMonitor (if using prometheus-operator)
kubectl get servicemonitor -n lynq-systemGrafana Dashboard
Import config/monitoring/grafana-dashboard.json via Dashboards → Import in the Grafana UI. Select your Prometheus datasource. The dashboard ships 17 panels grouped into four categories:
- Top-line stat panels: Total Desired / Ready / Failed Nodes, Total Conflicted Resources
- Reconciliation health: Reconciliation Duration percentiles, Reconciliation Rate, Error Rate, LynqNode Ready Status, Degraded Nodes
- Resource & conflict breakdowns: Resource Counts by Node and Total, Conflicted Resources by Node and Total, Conflicts Rate by Node
- Hub & runtime internals: Hub Health, Apply Rate by Kind, Work Queue Depth
Metrics Catalog
| Metric | Type | Labels | Description |
|---|---|---|---|
lynqnode_reconcile_duration_seconds | Histogram | result | Duration of LynqNode reconciliation in seconds |
lynqnode_resources_ready | Gauge | lynqnode, namespace | Number of ready resources for a LynqNode |
lynqnode_resources_desired | Gauge | lynqnode, namespace | Total number of desired resources for a LynqNode |
lynqnode_resources_failed | Gauge | lynqnode, namespace | Number of failed resources for a LynqNode |
hub_desired | Gauge | hub, namespace | Number of desired LynqNodes from the hub data source |
hub_ready | Gauge | hub, namespace | Number of ready LynqNodes for a hub |
hub_failed | Gauge | hub, namespace | Number of failed LynqNodes for a hub |
apply_attempts_total | Counter | kind, result, conflict_policy | Total number of resource apply attempts |
lynqnode_condition_status | Gauge | lynqnode, namespace, type | Status of LynqNode conditions (0=False, 1=True, 2=Unknown) |
lynqnode_conflicts_total | Counter | lynqnode, namespace, resource_kind, conflict_policy | Total number of resource conflicts encountered during reconciliation |
lynqnode_resources_conflicted | Gauge | lynqnode, namespace | Number of resources currently in conflict state for a LynqNode |
lynqnode_degraded_status | Gauge | lynqnode, namespace, reason | Indicates if a LynqNode is in degraded state (1=degraded, 0=not degraded) |
lynqform_rollout_updating_nodes | Gauge | form, namespace | Number of nodes currently being updated for a LynqForm (updated, update not completed yet; recovering nodes excluded) |
lynqform_rollout_phase | Gauge | form, namespace | Current rollout phase for a LynqForm (0=Idle, 1=InProgress, 2=Failed, 3=Complete) |
lynqform_rollout_progress | Gauge | form, namespace | Rollout progress percentage for a LynqForm (nodes that completed the update/totalNodes * 100) |
Generated from internal/metrics/metrics.go
hub_ready counts LynqNodes with Ready=True; hub_failed counts nodes that need an operator (failed or conflicted resources, or Degraded). A node that is rolling out or recovering lost pods is in neither, so hub_desired - hub_ready - hub_failed is the number still progressing. The lynqform_rollout_* metrics exist since v1.1.16.
For PromQL queries using these metrics, see Prometheus Query Examples.
Events
Kubernetes events are emitted for key lifecycle transitions.
# Events for a specific node
kubectl describe lynqnode <name>
# All LynqNode events
kubectl get events -A --field-selector involvedObject.kind=LynqNode --sort-by='.lastTimestamp'| Reason | Type | Recorded by | Message |
|---|---|---|---|
DataUpdated | Normal | LynqHub controller | LynqNode data updated from registry '…'. |
LynqNodeDeleted | Normal | LynqNode controller | LynqNode … deleted successfully. Resources will be cleaned up by Kubernetes garbage collector. |
NodeDeleted | Normal | LynqHub controller | Successfully deleted LynqNode '…' (template: …, uid: …) |
NodeDeleting | Normal | LynqHub controller | Deleting LynqNode '…' (template: …, uid: …) - no longer in active dataset. |
OrphanedResourceDeleted | Normal | LynqNode controller | Deleted orphaned resource …/… (ID: …) - removed from template |
OrphanedResourceRetained | Normal | LynqNode controller | Retained orphaned resource …/… (ID: …) - removed from template, marked with orphan labels |
OrphanMarkersAdded | Normal | internal/apply | built at runtime |
OrphanMarkersRemoved | Normal | internal/apply | Resource re-adopted into management - orphan markers removed |
ResourceRetained | Normal | LynqNode controller | Resource …/… retained with orphan labels (ownerReferences removed) |
RetainResourcePreserved | Normal | LynqHub controller | Removed ownerReference from resource … (policy=Retain) |
RolloutRecovered | Normal | LynqForm controller | Rollout is no longer stalled (phase …): … |
RolloutThrottled | Normal | LynqHub controller | LynqForm '…': … node updates throttled (maxSkew=…, currently updating=…) |
TemplateApplied | Normal | LynqHub controller | Applying LynqForm '…' changes (generation: … -> …). |
TemplateAppliedSuccess | Normal | LynqNode controller | Successfully applied LynqForm '…' (generation: …). |
TemplateResourcesApplying | Normal | LynqNode controller | Applying resources from LynqForm '…' (generation: …). |
ValidationPassed | Normal | LynqForm controller | Template validation passed successfully |
ApplyFailed | Warning | LynqNode controller | Failed to apply resource …: … |
CleanupFailed | Warning | LynqHub controller | Failed to cleanup retain resources: … |
CleanupPartialFailure | Warning | LynqNode controller | Some resources could not be cleaned up: …. Kubernetes garbage collector will handle remaining resources with ownerReferences. |
DatabaseQueryFailed | Warning | LynqHub controller | Failed to query database: … |
DependencyFailedButProceeding | Warning | LynqNode controller | Dependency '…' failed, but creating resource '…' anyway (skipOnDependencyFailure=false) |
DependencySkipped | Warning | LynqNode controller | Resource '…' skipped because dependency '…' failed. Set skipOnDependencyFailure=false to create anyway. |
DependencyValidationFailed | Warning | LynqForm controller | Dependency graph validation failed: … |
DuplicateResourceIDs | Warning | LynqForm controller | Found duplicate resource IDs: … |
HubNotFound | Warning | LynqForm controller | Referenced LynqHub '…' not found in namespace '…' |
NodeDeletionFailed | Warning | LynqHub controller | Failed to delete LynqNode '…': … |
ProgressDeadlineExceeded | Warning | LynqNode controller | Resource '…' stopped making rollout progress (Progressing=False, reason ProgressDeadlineExceeded) |
ReadinessTimeout | Warning | LynqNode controller | Resource '…' not ready after … (timeout: …) |
ResourceConflict | Warning | LynqNode controller | Resource conflict detected for …/… (Kind: …, Policy: …). |
RetainResourceProcessFailed | Warning | LynqHub controller | Failed to process retain resources for node …: … |
RolloutFailed | Warning | LynqForm controller | built at runtime |
TemplateAppliedPartial | Warning | LynqNode controller | Applied LynqForm '…' (generation: …) with partial success. |
TemplateRenderError | Warning | LynqNode controller | Failed to render resource …: … |
TemplateRenderFailed | Warning | LynqHub controller | Failed to render template for node …: … |
ValidationFailed | Warning | LynqForm controller | Template validation failed: … |
Every reason recorded in internal
Logging
Configure log level via the --zap-log-level flag: debug, info (default), error.
All logs are structured JSON:
{"level":"info","ts":"2025-01-15T10:30:00Z","msg":"Reconciliation completed","lynqnode":"acme-web","ready":10,"failed":0}# Follow all logs
kubectl logs -n lynq-system deployment/lynq-controller-manager -f
# Errors only
kubectl logs -n lynq-system deployment/lynq-controller-manager | grep '"level":"error"'
# Specific node
kubectl logs -n lynq-system deployment/lynq-controller-manager | grep "acme-web"Alerting
Alert rules are in config/prometheus/alerts.yaml. Deploy with:
kubectl apply -f config/prometheus/alerts.yaml| Alert | Severity | Fires when | For |
|---|---|---|---|
LynqNodeDegraded | critical | max by (lynqnode, namespace, reason) (lynqnode_degraded_status) > 0 | 5m |
LynqNodeResourcesFailed | critical | lynqnode_resources_failed > 0 | 5m |
LynqNodeNotReady | critical | lynqnode_condition_status{type="Ready"} == 0 | 15m |
LynqNodeStatusUnknown | critical | lynqnode_condition_status{type="Ready"} == 2 | 10m |
HubManyNodesFailure | critical | hub_failed > 5 or (hub_failed / hub_desired > 0.5 and hub_desired > 0) | 5m |
LynqNodeResourcesMismatch | warning | (lynqnode_resources_ready != lynqnode_resources_desired)
and (lynqnode_resources_desired > 0)
and (lynqnode_resources_failed == 0) | 15m |
LynqNodeResourcesConflicted | warning | lynqnode_resources_conflicted > 0 | 10m |
LynqNodeHighConflictRate | warning | rate(lynqnode_conflicts_total[5m]) > 0.1 | 10m |
HubNodesFailure | warning | hub_failed > 0 and hub_failed <= 5 | 10m |
HubDesiredCountMismatch | warning | (hub_ready != hub_desired)
and (hub_desired > 0)
and (hub_failed == 0) | 20m |
LynqFormRolloutFailed | warning | lynqform_rollout_phase == 2 | 5m |
LynqNodeReconciliationErrors | warning | sum(rate(lynqnode_reconcile_duration_seconds_count{result="error"}[5m]))
/
sum(rate(lynqnode_reconcile_duration_seconds_count[5m]))
> 0.1 | 10m |
LynqNodeReconciliationSlow | warning | histogram_quantile(0.95,
sum by (le) (rate(lynqnode_reconcile_duration_seconds_bucket{result="success"}[5m]))
) > 30 | 15m |
HighApplyFailureRate | warning | sum by (kind) (rate(apply_attempts_total{result="error"}[5m]))
/
sum by (kind) (rate(apply_attempts_total[5m]))
> 0.2 | 10m |
LynqNodeNewConflictsDetected | info | increase(lynqnode_conflicts_total[5m]) > 0 | 2m |
Generated from config/prometheus/alerts.yaml
For per-alert diagnosis and resolution steps, see Alert Runbooks.
See Also
- Prometheus Query Examples — PromQL cookbook (50+ queries)
- Alert Runbooks — per-alert diagnosis and resolution
- Troubleshooting — symptom-based diagnosis
- Performance — scaling and optimization
lynq render (CLI)
Render a LynqForm against rows from a CSV or JSON file and print the objects Lynq would apply, without a cluster or a database. Uses the same rendering code as the controllers.
Prometheus Query Examples
Production-ready Prometheus query examples for Lynq: health, performance, conflicts, rollouts, and hub metrics.