Parts 2 and 3 produced good data: vCenter metrics from the vcenter receiver and parsed ESXi logs from the syslog receiver. Data in a collector is not useful until it lands somewhere you can query, keep for the right length of time, and alert on. This is where most OpenTelemetry projects stall, not because the backends are hard, but because nobody explains what happens to the names on the way in. vcenter.host.cpu.utilization becomes vcenter_host_cpu_utilization_percent in Prometheus, a resource attribute either becomes a label or quietly disappears into target_info, and Loki decides on its own which attributes it indexes. This part builds the whole backend in one Compose file, explains those translation rules so your queries work the first time, and finishes with a provisioned Grafana dashboard and alert rules that join metrics and logs on the ESXi host name.
Level: intermediate · Stack: otelcol-contrib 0.166.0, Prometheus 3.16 (or Mimir 3.2), Loki 3.7, Tempo 3.1, Grafana 13.3, Docker Compose or Podman · Build time: about 45 minutes
Contents
- What we are building
- Architecture
- Choosing the exporters
- How OpenTelemetry names become Prometheus names
- How Loki stores OTLP logs
- The stack: Compose and backend configs
- Grafana provisioning and the dashboard
- Alert rules
- Correlating logs and metrics by host
- Retention, cardinality and sizing
- End-to-end workflow
- Troubleshooting
01. What we are building
One Linux VM running five containers: the OpenTelemetry Collector as the gateway, Prometheus for metrics (Mimir as the scale-out swap), Loki for logs, Tempo for traces, and Grafana on top with its data sources, a vSphere dashboard and five alert rules provisioned from files. Everything is configuration in a directory you can keep in git; nothing is clicked together in a UI.
| Signal | Source in this series | Collector exporter | Store | Query language |
|---|---|---|---|---|
| Metrics | vcenter receiver (part 2), OTLP from apps | prometheus_remote_write | Prometheus 3.x or Mimir | PromQL |
| Logs | syslog receiver (part 3), OTLP from apps | otlp_http to /otlp | Loki 3.x | LogQL |
| Traces | OTLP from applications (parts 5 and 6) | otlp_grpc | Tempo 3.x | TraceQL |
vSphere itself produces no traces; Tempo is here because the series ends with a request trace that leads to a datastore, and it costs nothing to wire up now. If you are coming from Telegraf and InfluxDB, the design trade-offs in wiring Grafana into vCenter still apply; this post is the OpenTelemetry version of the same destination.
02. Architecture
Three rules shape this layout. First, the collector is the only thing that talks to vCenter and the only thing ESXi hosts send syslog to; backends never see the sources directly, so you can swap Prometheus for Mimir without touching a host. Second, each signal has its own store, because each store is good at exactly one thing. Third, Grafana is the only place signals meet, and they meet on shared keys (host name, datastore name, trace ID) that the collector puts in place on the way through. Section 09 is about those keys.
03. Choosing the exporters
Collector component names changed during 2026: prometheusremotewrite is now prometheus_remote_write with its HTTP settings under an http: block, otlp and otlphttp exporters are now otlp_grpc and otlp_http (the receiver is still otlp), and the old names remain as deprecated aliases that log a warning. The batch processor is deprecated as of v0.166.0; batching now belongs in each exporter’s sending_queue.batch block. All configuration below uses the current names and validates on 0.166.0.
Metrics: remote write or OTLP?
| Option | Endpoint | Labels from resource attributes | Use it when |
|---|---|---|---|
prometheus_remote_write to Prometheus | /api/v1/write, needs --web.enable-remote-write-receiver | Exporter decides: resource_constant_labels.included | Default. Works with Prometheus, Mimir, Thanos, VictoriaMetrics alike. Beta. |
otlp_http to Prometheus 3.x | /api/v1/otlp/v1/metrics, needs --web.enable-otlp-receiver | Prometheus decides: otlp.promote_resource_attributes in prometheus.yml | You want one protocol end to end and control on the server side. |
prometheus_remote_write to Mimir | /api/v1/push, tenant in X-Scope-OrgID | Exporter decides, as above | Long retention, multiple Prometheus-sized estates, HA. |
otlp_http to Mimir | /otlp (exporter appends /v1/metrics) | Mimir decides, per tenant | Mimir shops standardising on OTLP. |
The detail that bites everyone: with remote write, resource attributes do not become labels by default. They go to a separate target_info series, and you would have to join against it in every query. vCenter metrics carry everything useful (cluster, host, VM, datastore) as resource attributes, so set resource_constant_labels.included to the patterns you want as labels. That option replaced resource_to_telemetry_conversion, which is deprecated. Promote only what you filter or group by; every promoted attribute is a label on every series.
exporters:
# A. Mimir through remote write (same label behaviour as Prometheus)
prometheus_remote_write/mimir:
http:
endpoint: https://<MIMIR_HOST>/api/v1/push
headers:
X-Scope-OrgID: <TENANT_ID>
resource_constant_labels:
included: ["vcenter.*", "host.name", "site", "deployment.environment.name"]
target_info:
enabled: false
# B. Mimir native OTLP (the exporter appends /v1/metrics)
otlp_http/mimir:
endpoint: https://<MIMIR_HOST>/otlp
headers:
X-Scope-OrgID: <TENANT_ID>
sending_queue:
batch:
flush_timeout: 5s
# C. Prometheus 3.x native OTLP (needs --web.enable-otlp-receiver and the otlp: block)
otlp_http/prometheus:
metrics_endpoint: http://prometheus:9090/api/v1/otlp/v1/metrics
sending_queue:
batch:
flush_timeout: 5s
Logs: otlp_http to Loki’s native endpoint
Loki 3 ingests OTLP natively at http://<loki>:3100/otlp, and the otlp_http exporter appends /v1/logs. That is now the recommended path. The dedicated loki exporter was deprecated in July 2024 and has been removed from contrib, so older blog posts that use it will not work on a current collector. Loki needs allow_structured_metadata: true (the default since 3.0) and a TSDB index with schema v13, or it rejects OTLP payloads.
Traces: otlp_grpc to Tempo
Tempo’s distributor accepts OTLP on 4317 and 4318. Inside the Compose network there is no TLS, so the exporter needs tls.insecure: true; without it the gRPC handshake fails and the error message mentions TLS, not Tempo.
04. How OpenTelemetry names become Prometheus names
Prometheus metric names cannot contain dots, and by convention they end in a unit and, for counters, _total. The translation is done by the Prometheus project’s otlptranslator library, shared by the remote write exporter and Prometheus’s own OTLP receiver, under the default strategy UnderscoreEscapingWithSuffixes. The rules, read from the library source:
- Every character outside
[a-zA-Z0-9:]becomes_, and runs of underscores collapse. - The unit is mapped through a fixed table and appended:
mstomilliseconds,ustomicroseconds,Bytobytes,MiBytomebibytes,KiBytokibibytes,%topercent,1to nothing. A unit that is not in the table is appended as written, which is whyMHzsurvives with its capital letters. - Units in curly braces are annotations and are dropped, so
{KiBy/s},{hosts}and{alarms}add no suffix at all. - Monotonic cumulative sums get
_total. Non-monotonic sums (all the vCenter capacity and usage “sums”) are gauges in Prometheus and get no_total. - Gauges with unit
1get_ratio. - Attribute names follow the same character rule, so
vcenter.host.namebecomes the labelvcenter_host_name.
| OpenTelemetry metric | Unit, type | Prometheus name |
|---|---|---|
vcenter.host.cpu.utilization | %, gauge | vcenter_host_cpu_utilization_percent |
vcenter.host.cpu.usage | MHz, non-monotonic sum | vcenter_host_cpu_usage_MHz |
vcenter.host.memory.utilization | %, gauge | vcenter_host_memory_utilization_percent |
vcenter.host.memory.usage | MiBy, non-monotonic sum | vcenter_host_memory_usage_mebibytes |
vcenter.host.disk.latency.avg | ms, gauge | vcenter_host_disk_latency_avg_milliseconds |
vcenter.host.network.throughput | {KiBy/s}, non-monotonic sum | vcenter_host_network_throughput |
vcenter.host.vsan.latency.avg | us, gauge | vcenter_host_vsan_latency_avg_microseconds |
vcenter.vm.cpu.readiness | %, gauge | vcenter_vm_cpu_readiness_percent |
vcenter.vm.disk.latency.avg | ms, gauge | vcenter_vm_disk_latency_avg_milliseconds |
vcenter.vm.memory.usage | MiBy, non-monotonic sum | vcenter_vm_memory_usage_mebibytes |
vcenter.datastore.disk.usage | By, non-monotonic sum | vcenter_datastore_disk_usage_bytes |
vcenter.datastore.disk.utilization | %, gauge | vcenter_datastore_disk_utilization_percent |
vcenter.cluster.vm.count | {virtual_machines}, non-monotonic sum | vcenter_cluster_vm_count |
Never guess a name in a dashboard: list what actually arrived with curl -s http://localhost:9090/api/v1/label/__name__/values | jq -r '.data[]' | grep ^vcenter_. Two vCenter receiver facts to keep in mind while building panels: the receiver is alpha and every one of its metrics is marked development stability, so names can still change between releases, and its README lists vSphere 7.0 and 8 as the tested versions. Check the changelog before every collector upgrade.
05. How Loki stores OTLP logs
Loki maps an OTLP log record onto its own model with fixed rules, and knowing them is the difference between fast and slow queries:
- The log line is the record body. Part 3 sets the body to the human readable ESXi message.
- A default list of 17 resource attributes becomes index labels, including
service.name,service.namespace,deployment.environment.name,k8s.*names andcloud.region.host.nameis not on the list. - Every other resource attribute, all scope attributes and all log record attributes (including severity and trace context) become structured metadata: stored with the line, not indexed, filterable with
| key="value". - Dots and other characters invalid in label names become underscores:
service.nameis queried asservice_name,esx.eventasesx_event. - A record with no
service.namelands inservice_name="unknown_service", which is why part 3 setsservice.name=esxion every ESXi record.
So an ESXi query always starts with the stream selector {service_name="esxi"} and narrows with pipes: {service_name="esxi"} | host_name="esx01.lab.local" | esx_event="apd_start". That form works whether host_name is structured metadata or an index label. The Loki configuration in section 06 promotes host.name to an index label with limits_config.otlp_config, because “all logs from one host” is the most common ESXi query and the label count is bounded by your host count. Do not promote anything with unbounded values (device IDs, opIDs, VM names); Loki’s default limit is 15 index labels per stream and every extra label value multiplies streams.
06. The stack: Compose and backend configs
The directory layout, then every file. Create the directory, drop the files in, create .env, and docker compose up -d (or podman compose up -d).
vsphere-otel-stack/
├── compose.yaml
├── .env # secrets, chmod 600, never committed
├── otelcol/config.yaml
├── prometheus/prometheus.yml
├── loki/loki.yaml
├── tempo/tempo.yaml
└── grafana/
├── provisioning/
│ ├── datasources/datasources.yaml
│ ├── dashboards/dashboards.yaml
│ └── alerting/vsphere-rules.yaml
└── dashboards/vsphere-overview.json
# vsphere-otel-stack/.env (chmod 600; add to .gitignore)
VCENTER_USERNAME=<SVC_ACCOUNT>@vsphere.local
VCENTER_PASSWORD=<VCENTER_PASSWORD>
GRAFANA_ADMIN_PASSWORD=<GRAFANA_ADMIN_PASSWORD>
compose.yaml
# vsphere-otel-stack/compose.yaml
# docker compose up -d (or: podman compose up -d)
# Secrets come from ./.env, which you create and keep out of git.
name: vsphere-otel
services:
otelcol:
image: otel/opentelemetry-collector-contrib:0.166.0
command: ["--config=/etc/otelcol-contrib/config.yaml"]
restart: unless-stopped
env_file: .env
mem_limit: 2g
volumes:
- ./otelcol/config.yaml:/etc/otelcol-contrib/config.yaml:ro
ports:
- "1514:1514" # ESXi syslog, TCP, RFC 3164
- "5514:5514" # ESXi syslog, TCP, RFC 5424 + octet counting
- "4317:4317" # OTLP gRPC from apps and agent collectors
- "4318:4318" # OTLP HTTP
- "13133:13133" # health_check
depends_on: [prometheus, loki, tempo]
prometheus:
image: prom/prometheus:v3.16.0
restart: unless-stopped
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --storage.tsdb.retention.time=30d
- --storage.tsdb.retention.size=40GB
- --web.enable-remote-write-receiver
- --web.enable-otlp-receiver
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus
ports:
- "9090:9090"
loki:
image: grafana/loki:3.7.10
restart: unless-stopped
command: ["-config.file=/etc/loki/loki.yaml"]
volumes:
- ./loki/loki.yaml:/etc/loki/loki.yaml:ro
- loki-data:/loki
ports:
- "3100:3100"
tempo:
image: grafana/tempo:3.1.1
restart: unless-stopped
command: ["-target=all", "-config.file=/etc/tempo.yaml"]
volumes:
- ./tempo/tempo.yaml:/etc/tempo.yaml:ro
- tempo-data:/var/tempo
ports:
- "3200:3200"
grafana:
image: grafana/grafana:13.3.1
restart: unless-stopped
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
- GF_USERS_ALLOW_SIGN_UP=false
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning:ro
- ./grafana/dashboards:/var/lib/grafana/dashboards:ro
- grafana-data:/var/lib/grafana
ports:
- "3000:3000"
depends_on: [prometheus, loki, tempo]
volumes:
prometheus-data:
loki-data:
tempo-data:
grafana-data:
Image tags are pinned to versions that were current in late November 2026; pin, do not use latest, because a Loki or Tempo major version changes configuration keys. On RHEL with Podman and SELinux enforcing, add :Z to the bind mounts. The syslog ports are 1514 and 5514, so rootless Podman needs no privileged-port tweak.
otelcol/config.yaml
The gateway configuration. It combines the vCenter receiver from part 2 and the syslog receivers from part 3 (with the operators that set host.name and service.name), adds an otlp receiver for applications, and sends each signal to its store. Paste transform/esx_events from part 3 into the processors and the logs/esx pipeline to get the parsed event fields.
# vsphere-otel-stack/otelcol/config.yaml
# Gateway collector: vCenter metrics + ESXi syslog + OTLP in; Prometheus, Loki, Tempo out.
# Env (from .env): VCENTER_USERNAME, VCENTER_PASSWORD
extensions:
health_check:
endpoint: 0.0.0.0:13133
receivers:
vcenter:
endpoint: https://<VCENTER_FQDN>
username: ${env:VCENTER_USERNAME}
password: ${env:VCENTER_PASSWORD}
collection_interval: 2m
tls:
insecure_skip_verify: false
# ca_file: /etc/otelcol-contrib/vcenter-ca.pem
syslog/esx_3164:
tcp:
listen_address: 0.0.0.0:1514
protocol: rfc3164
location: UTC
on_error: send_quiet
operators: &esx_ops
- type: add
field: resource["host.name"]
value: EXPR(lower(attributes.hostname))
on_error: send_quiet
- type: remove
field: attributes.hostname
on_error: send_quiet
- type: add
id: svc_name
field: resource["service.name"]
value: esxi
- type: add
id: svc_ns
field: resource["service.namespace"]
value: vsphere
syslog/esx_5424:
tcp:
listen_address: 0.0.0.0:5514
protocol: rfc5424
enable_octet_counting: true
on_error: send_quiet
operators: *esx_ops
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
memory_limiter:
check_interval: 1s
limit_percentage: 80
spike_limit_percentage: 25
# One join key for logs and metrics: host.name = lower-case ESXi name, on host resources only.
# vcenter.host.name is left exactly as vCenter reports it, so part 2 queries keep working.
transform/vsphere_metrics:
error_mode: ignore
metric_statements:
- context: resource
statements:
- 'set(resource.attributes["vcenter.server"], "<VCENTER_FQDN>")'
- 'set(resource.attributes["host.name"], ConvertCase(resource.attributes["vcenter.host.name"], "lower")) where resource.attributes["vcenter.host.name"] != nil and resource.attributes["vcenter.vm.name"] == nil and resource.attributes["vcenter.resource_pool.name"] == nil'
# If vCenter inventory uses FQDNs but ESXi syslog sends short names, uncomment:
# - 'replace_pattern(resource.attributes["host.name"], "^([^.]+)\\..*", "$$1")'
# Paste transform/esx_events from Part 3 here and add it to logs/esx below.
exporters:
prometheus_remote_write:
http:
endpoint: http://prometheus:9090/api/v1/write
resource_constant_labels:
included: ["vcenter.*", "host.name", "site", "deployment.environment.name"]
target_info:
enabled: false
otlp_http/loki:
endpoint: http://loki:3100/otlp
sending_queue:
batch:
flush_timeout: 2s
otlp_grpc/tempo:
endpoint: tempo:4317
tls:
insecure: true
sending_queue:
batch:
flush_timeout: 2s
service:
extensions: [health_check]
telemetry:
metrics:
level: normal
readers:
- pull:
exporter:
prometheus:
host: 0.0.0.0
port: 8888
pipelines:
metrics/vsphere:
receivers: [vcenter]
processors: [memory_limiter, transform/vsphere_metrics]
exporters: [prometheus_remote_write]
logs/esx:
receivers: [syslog/esx_3164, syslog/esx_5424]
processors: [memory_limiter]
exporters: [otlp_http/loki]
logs/otlp:
receivers: [otlp]
processors: [memory_limiter]
exporters: [otlp_http/loki]
traces:
receivers: [otlp]
processors: [memory_limiter]
exporters: [otlp_grpc/tempo]
metrics/otlp:
receivers: [otlp]
processors: [memory_limiter]
exporters: [prometheus_remote_write]
prometheus/prometheus.yml
# vsphere-otel-stack/prometheus/prometheus.yml
global:
scrape_interval: 30s
evaluation_interval: 30s
storage:
tsdb:
# Remote-write and OTLP pushes can arrive late after a collector restart or queue drain.
out_of_order_time_window: 30m
# Only used if you push with OTLP (/api/v1/otlp/v1/metrics) instead of remote write.
otlp:
promote_resource_attributes:
- host.name
- vcenter.datacenter.name
- vcenter.cluster.name
- vcenter.host.name
- vcenter.vm.name
- vcenter.vm.id
- vcenter.datastore.name
- vcenter.resource_pool.name
translation_strategy: UnderscoreEscapingWithSuffixes
scrape_configs:
- job_name: otelcol
static_configs:
- targets: ["otelcol:8888"]
- job_name: loki
static_configs:
- targets: ["loki:3100"]
- job_name: tempo
static_configs:
- targets: ["tempo:3200"]
Retention is set on the command line in Compose: --storage.tsdb.retention.time=30d and a size cap of 40 GB, whichever is hit first. The otlp: block only matters if you switch the collector to the native OTLP endpoint; with remote write, the collector decides the labels. The 30 minute out-of-order window is Prometheus’s own recommendation for OTLP ingestion and also covers a collector replaying its queue after a restart.
loki/loki.yaml
# vsphere-otel-stack/loki/loki.yaml (single binary, filesystem storage)
auth_enabled: false
server:
http_listen_port: 3100
grpc_listen_port: 9096
log_level: info
common:
instance_addr: 127.0.0.1
path_prefix: /loki
storage:
filesystem:
chunks_directory: /loki/chunks
rules_directory: /loki/rules
replication_factor: 1
ring:
kvstore:
store: inmemory
schema_config:
configs:
- from: 2026-01-01
store: tsdb
object_store: filesystem
schema: v13
index:
prefix: index_
period: 24h
limits_config:
allow_structured_metadata: true
retention_period: 720h # 30 days for everything...
retention_stream:
- selector: '{service_name="esxi"}'
priority: 1
period: 2160h # ...except ESXi logs, kept 90 days
otlp_config:
resource_attributes:
attributes_config:
- action: index_label
attributes:
- host.name
compactor:
working_directory: /loki/compactor
compaction_interval: 10m
retention_enabled: true
retention_delete_delay: 2h
delete_request_store: filesystem
analytics:
reporting_enabled: false
Retention is done by the compactor and needs retention_enabled: true plus a delete_request_store. The retention_stream rule keeps ESXi logs for 90 days while everything else goes after 30, which is the right way round for infrastructure logs you only need during the incident review.
tempo/tempo.yaml
# vsphere-otel-stack/tempo/tempo.yaml (Tempo 3.x, single binary, local storage)
stream_over_http_enabled: true
server:
http_listen_port: 3200
log_level: info
distributor:
receivers:
otlp:
protocols:
grpc:
endpoint: "0.0.0.0:4317"
http:
endpoint: "0.0.0.0:4318"
metrics_generator:
registry:
external_labels:
source: tempo
storage:
path: /var/tempo/generator/wal
remote_write:
- url: http://prometheus:9090/api/v1/write
send_exemplars: true
storage:
trace:
backend: local
wal:
path: /var/tempo/wal
local:
path: /var/tempo/blocks
overrides:
defaults:
metrics_generator:
processors: ["service-graphs", "span-metrics"]
compaction:
block_retention: 168h
usage_report:
reporting_enabled: false
This follows the single-binary example shipped with Tempo 3.1. The metrics generator writes span-derived metrics into Prometheus, which powers the service graph in Grafana. Retention for Tempo 3 is a per-tenant override, overrides.defaults.compaction.block_retention.
07. Grafana provisioning and the dashboard
Data sources
# vsphere-otel-stack/grafana/provisioning/datasources/datasources.yaml
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
uid: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: false
jsonData:
httpMethod: POST
timeInterval: 2m # matches vcenter receiver collection_interval
exemplarTraceIdDestinations:
- name: trace_id
datasourceUid: tempo
- name: Loki
type: loki
uid: loki
access: proxy
url: http://loki:3100
editable: false
jsonData:
maxLines: 5000
derivedFields:
- name: TraceID
matcherType: label
matcherRegex: trace_id
datasourceUid: tempo
url: "$${__value.raw}"
urlDisplayLabel: Open trace
- name: Tempo
type: tempo
uid: tempo
access: proxy
url: http://tempo:3200
editable: false
jsonData:
serviceMap:
datasourceUid: prometheus
tracesToLogsV2:
datasourceUid: loki
spanStartTimeShift: "-5m"
spanEndTimeShift: "5m"
filterByTraceID: true
tags:
- key: host.name
value: host_name
tracesToMetrics:
datasourceUid: prometheus
Three things in this file are easy to get wrong. The data source uid values are fixed (prometheus, loki, tempo) because the dashboard and alert rules reference them. The Loki derived field uses matcherType: label, which matches a structured metadata key such as trace_id, not a regex over the line. And $${__value.raw} is written with two dollar signs, because Grafana expands environment variables in provisioning files and a single $ would be replaced by an empty string. timeInterval: 2m matches the vCenter receiver’s collection interval, so panels do not draw gaps between samples.
Dashboard provider
# vsphere-otel-stack/grafana/provisioning/dashboards/dashboards.yaml
apiVersion: 1
providers:
- name: vsphere
folder: vSphere
type: file
disableDeletion: true
allowUiUpdates: false
options:
path: /var/lib/grafana/dashboards
Dashboard: vSphere overview
A starting dashboard with three variables (datacenter, cluster, ESXi host) and four rows: host CPU, memory, device latency and network; top-10 VMs by CPU ready and virtual disk latency; datastore utilisation and free space; and ESXi log events from part 3. The host variable takes its values from the host_name label on host metrics, which is the same lower-case name the syslog pipeline puts on logs, so one selection filters both. VM panels match vcenter_host_name case-insensitively with (?i), since that label keeps vCenter’s original spelling.
{
"uid": "vsphere-otel-overview",
"title": "vSphere overview (OpenTelemetry)",
"tags": [
"vsphere",
"opentelemetry"
],
"timezone": "browser",
"schemaVersion": 39,
"version": 1,
"editable": false,
"refresh": "2m",
"time": {
"from": "now-6h",
"to": "now"
},
"templating": {
"list": [
{
"name": "datacenter",
"label": "Datacenter",
"type": "query",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"query": "label_values(vcenter_host_cpu_utilization_percent, vcenter_datacenter_name)",
"definition": "label_values(vcenter_host_cpu_utilization_percent, vcenter_datacenter_name)",
"refresh": 2,
"multi": true,
"includeAll": true,
"allValue": ".*",
"current": {},
"sort": 1
},
{
"name": "cluster",
"label": "Cluster",
"type": "query",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"query": "label_values(vcenter_host_cpu_utilization_percent{vcenter_datacenter_name=~\"$datacenter\"}, vcenter_cluster_name)",
"definition": "label_values(vcenter_host_cpu_utilization_percent{vcenter_datacenter_name=~\"$datacenter\"}, vcenter_cluster_name)",
"refresh": 2,
"multi": true,
"includeAll": true,
"allValue": ".*",
"current": {},
"sort": 1
},
{
"name": "esx_host",
"label": "ESXi host",
"type": "query",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"query": "label_values(vcenter_host_cpu_utilization_percent{vcenter_cluster_name=~\"$cluster\"}, host_name)",
"definition": "label_values(vcenter_host_cpu_utilization_percent{vcenter_cluster_name=~\"$cluster\"}, host_name)",
"refresh": 2,
"multi": true,
"includeAll": true,
"allValue": ".*",
"current": {},
"sort": 1
}
]
},
"annotations": {
"list": []
},
"panels": [
{
"id": 1,
"type": "row",
"title": "Hosts",
"collapsed": false,
"gridPos": {
"x": 0,
"y": 0,
"w": 24,
"h": 1
},
"panels": []
},
{
"id": 2,
"type": "timeseries",
"title": "Host CPU utilization",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 1,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "percent",
"custom": {
"lineWidth": 1,
"fillOpacity": 10,
"thresholdsStyle": {
"mode": "line"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 80
},
{
"color": "red",
"value": 90
}
]
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "right",
"calcs": [
"lastNotNull",
"max"
]
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "vcenter_host_cpu_utilization_percent{vcenter_cluster_name=~\"$cluster\", host_name=~\"$esx_host\"}",
"legendFormat": "{{host_name}}"
}
]
},
{
"id": 3,
"type": "timeseries",
"title": "Host memory utilization",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 1,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "percent",
"custom": {
"lineWidth": 1,
"fillOpacity": 10,
"thresholdsStyle": {
"mode": "line"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 85
},
{
"color": "red",
"value": 95
}
]
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "right",
"calcs": [
"lastNotNull",
"max"
]
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "vcenter_host_memory_utilization_percent{vcenter_cluster_name=~\"$cluster\", host_name=~\"$esx_host\"}",
"legendFormat": "{{host_name}}"
}
]
},
{
"id": 4,
"type": "timeseries",
"title": "Device latency (avg, read+write)",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 9,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "ms",
"custom": {
"lineWidth": 1,
"fillOpacity": 10,
"thresholdsStyle": {
"mode": "line"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 10
},
{
"color": "red",
"value": 20
}
]
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "right",
"calcs": [
"lastNotNull",
"max"
]
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "max by (host_name, object) (vcenter_host_disk_latency_avg_milliseconds{vcenter_cluster_name=~\"$cluster\", host_name=~\"$esx_host\", object!=\"\"})",
"legendFormat": "{{host_name}} {{object}}"
}
]
},
{
"id": 5,
"type": "timeseries",
"title": "Host network throughput",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 9,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "KiBs",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "right",
"calcs": [
"lastNotNull",
"max"
]
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (host_name, direction) (vcenter_host_network_throughput{vcenter_cluster_name=~\"$cluster\", host_name=~\"$esx_host\", object!=\"\"})",
"legendFormat": "{{host_name}} {{direction}}"
}
]
},
{
"id": 6,
"type": "row",
"title": "Virtual machines",
"collapsed": false,
"gridPos": {
"x": 0,
"y": 17,
"w": 24,
"h": 1
},
"panels": []
},
{
"id": 7,
"type": "timeseries",
"title": "Top 10 VMs by CPU ready",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 18,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "percent",
"custom": {
"lineWidth": 1,
"fillOpacity": 10,
"thresholdsStyle": {
"mode": "line"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 5
},
{
"color": "red",
"value": 10
}
]
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "right",
"calcs": [
"lastNotNull",
"max"
]
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "topk(10, vcenter_vm_cpu_readiness_percent{vcenter_cluster_name=~\"$cluster\", vcenter_host_name=~\"(?i)$esx_host\"})",
"legendFormat": "{{vcenter_vm_name}} on {{vcenter_host_name}}"
}
]
},
{
"id": 8,
"type": "timeseries",
"title": "Top 10 VMs by virtual disk latency",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 18,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "ms",
"custom": {
"lineWidth": 1,
"fillOpacity": 10,
"thresholdsStyle": {
"mode": "line"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 10
},
{
"color": "red",
"value": 20
}
]
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "right",
"calcs": [
"lastNotNull",
"max"
]
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "topk(10, max by (vcenter_vm_name, vcenter_host_name) (vcenter_vm_disk_latency_avg_milliseconds{vcenter_cluster_name=~\"$cluster\", vcenter_host_name=~\"(?i)$esx_host\"}))",
"legendFormat": "{{vcenter_vm_name}} on {{vcenter_host_name}}"
}
]
},
{
"id": 9,
"type": "row",
"title": "Datastores",
"collapsed": false,
"gridPos": {
"x": 0,
"y": 26,
"w": 24,
"h": 1
},
"panels": []
},
{
"id": 10,
"type": "bargauge",
"title": "Datastore used",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 27,
"w": 12,
"h": 9
},
"fieldConfig": {
"defaults": {
"unit": "percent",
"min": 0,
"max": 100,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 80
},
{
"color": "red",
"value": 90
}
]
}
},
"overrides": []
},
"options": {
"orientation": "horizontal",
"displayMode": "gradient",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sort_desc(max by (vcenter_datastore_name) (vcenter_datastore_disk_utilization_percent{vcenter_datacenter_name=~\"$datacenter\"}))",
"legendFormat": "{{vcenter_datastore_name}}",
"instant": true
}
]
},
{
"id": 11,
"type": "timeseries",
"title": "Datastore free space",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 27,
"w": 12,
"h": 9
},
"fieldConfig": {
"defaults": {
"unit": "bytes",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "right",
"calcs": [
"lastNotNull",
"max"
]
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "max by (vcenter_datastore_name) (vcenter_datastore_disk_usage_bytes{vcenter_datacenter_name=~\"$datacenter\", disk_state=\"available\"})",
"legendFormat": "{{vcenter_datastore_name}}"
}
]
},
{
"id": 12,
"type": "row",
"title": "ESXi logs (Loki, joined on host name)",
"collapsed": false,
"gridPos": {
"x": 0,
"y": 36,
"w": 24,
"h": 1
},
"panels": []
},
{
"id": 13,
"type": "timeseries",
"title": "Parsed ESXi events by type",
"datasource": {
"type": "loki",
"uid": "loki"
},
"gridPos": {
"x": 0,
"y": 37,
"w": 24,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {
"drawStyle": "bars",
"fillOpacity": 60,
"stacking": {
"mode": "normal",
"group": "A"
}
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "loki",
"uid": "loki"
},
"expr": "sum by (esx_event) (count_over_time({service_name=\"esxi\"} | host_name=~\"$esx_host\" | esx_event!=\"\" [$__auto]))",
"legendFormat": "{{esx_event}}",
"queryType": "range"
}
]
},
{
"id": 14,
"type": "logs",
"title": "ESXi warnings and parsed events",
"datasource": {
"type": "loki",
"uid": "loki"
},
"gridPos": {
"x": 0,
"y": 45,
"w": 24,
"h": 12
},
"options": {
"showTime": true,
"wrapLogMessage": true,
"sortOrder": "Descending",
"enableLogDetails": true,
"dedupStrategy": "none"
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "loki",
"uid": "loki"
},
"expr": "{service_name=\"esxi\"} | host_name=~\"$esx_host\" | severity_number >= 13 or esx_event!=\"\"",
"queryType": "range"
}
]
}
]
}
08. Alert rules
Five Grafana-managed rules, provisioned from a file. Each uses an instant query (A) and a threshold expression (C), the shape Grafana itself exports. Thresholds are starting points; tune them on a week of your own data before you route them to a pager. Annotation templates use $$labels and $$values for the same provisioning reason as above.
# vsphere-otel-stack/grafana/provisioning/alerting/vsphere-rules.yaml
apiVersion: 1
groups:
- orgId: 1
name: vsphere-otel
folder: vSphere
interval: 1m
rules:
# 1. Block device latency seen by the host (VMFS / vVols / RDM; not NFS, see notes)
- uid: vsphere-device-latency
title: ESXi device latency high
condition: C
data:
- refId: A
relativeTimeRange: { from: 900, to: 0 }
datasourceUid: prometheus
model:
refId: A
instant: true
expr: >-
max by (vcenter_cluster_name, vcenter_host_name, object) (
max_over_time(vcenter_host_disk_latency_avg_milliseconds{object!=""}[10m])
)
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: { type: gt, params: [20] }
for: 10m
noDataState: OK
execErrState: Error
labels: { severity: warning, team: vsphere }
annotations:
summary: "{{ $$labels.vcenter_host_name }}: device {{ $$labels.object }} averaging {{ $$values.A }} ms"
description: Sustained device latency above 20 ms for 10 minutes. Check array side latency and queue depth before blaming the host.
# 2. CPU ready on a host, expressed through its worst VM
- uid: vsphere-cpu-ready
title: ESXi host CPU ready high
condition: C
data:
- refId: A
relativeTimeRange: { from: 1200, to: 0 }
datasourceUid: prometheus
model:
refId: A
instant: true
expr: >-
max by (vcenter_cluster_name, vcenter_host_name) (
avg_over_time(vcenter_vm_cpu_readiness_percent[15m])
)
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: { type: gt, params: [5] }
for: 15m
noDataState: OK
execErrState: Error
labels: { severity: warning, team: vsphere }
annotations:
summary: "{{ $$labels.vcenter_host_name }}: worst VM CPU ready {{ $$values.A }} percent"
description: At least one VM on this host has averaged more than 5 percent ready time for 15 minutes. Look at vCPU sizing and DRS balance.
# 3. Datastore free space
- uid: vsphere-datastore-full
title: Datastore above 85 percent used
condition: C
data:
- refId: A
relativeTimeRange: { from: 1800, to: 0 }
datasourceUid: prometheus
model:
refId: A
instant: true
expr: >-
max by (vcenter_datacenter_name, vcenter_datastore_name) (
max_over_time(vcenter_datastore_disk_utilization_percent[30m])
)
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: { type: gt, params: [85] }
for: 30m
noDataState: OK
execErrState: Error
labels: { severity: warning, team: vsphere }
annotations:
summary: "{{ $$labels.vcenter_datastore_name }} is {{ $$values.A }} percent used"
description: Snapshots and thin disks grow without asking. Check snapshot age and the growth trend panel.
# 4. APD events in ESXi logs (Loki)
- uid: esxi-apd-events
title: ESXi All Paths Down event
condition: C
data:
- refId: A
relativeTimeRange: { from: 600, to: 0 }
datasourceUid: loki
model:
refId: A
queryType: instant
expr: >-
sum by (host_name) (
count_over_time({service_name="esxi"} | esx_event=~"apd_start|apd_timeout" [5m])
)
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: { type: gt, params: [0] }
for: 0s
noDataState: OK
execErrState: Error
labels: { severity: critical, team: vsphere }
annotations:
summary: "{{ $$labels.host_name }} logged {{ $$values.A }} APD events in 5 minutes"
description: A device or NFS datastore entered All Paths Down. Check the storage.device and vcenter_datastore_name fields in Explore, then the array and the storage network.
# 5. The pipeline itself: vCenter metrics stopped arriving
- uid: vsphere-pipeline-stale
title: vCenter metrics stopped arriving
condition: C
data:
- refId: A
relativeTimeRange: { from: 900, to: 0 }
datasourceUid: prometheus
model:
refId: A
instant: true
expr: absent_over_time(vcenter_host_cpu_utilization_percent[10m])
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: { type: gt, params: [0] }
for: 5m
noDataState: OK
execErrState: Error
labels: { severity: critical, team: vsphere }
annotations:
summary: No vcenter_host_cpu_utilization_percent samples for 10 minutes
description: The collector, its vCenter login, or remote write is broken. Check otelcol health on port 13133 and the exporter send_failed metrics.
| Rule | Why this query | Watch out for |
|---|---|---|
| Device latency | max_over_time over 10 minutes per host and device, so one 2 minute sample does not page anyone | The vCenter receiver’s host disk latency comes from disk.* counters, which cover block devices (VMFS, vVols, RDM) but not NFS. For NFS datastore latency see NFS datastore latency with OpenTelemetry. |
| Host CPU ready | The receiver has no host-level ready metric; the worst VM on a host is the useful signal | vcenter.vm.cpu.readiness comes from the VM’s quick stats as a whole-VM percentage. Large VMs and small VMs on the same threshold is a compromise. |
| Datastore 85 percent | Simple, and the one that prevents a stun | Add a predict_linear rule on vcenter_datastore_disk_usage_bytes{disk_state="available"} once you trust the data. |
| APD events | LogQL count over 5 minutes from the part 3 fields, fires on the first event | vmkernel, vmkwarning and vobd all log the same APD, so counts are inflated; the rule uses > 0 and does not care. |
| Pipeline stale | absent_over_time on a metric that must always exist | Build this one first. It catches the expired service account password that silently empties every other rule. |
If you would rather alert on log-derived numbers in PromQL, the count connector turns log records into a counter inside the collector. It emits delta sums, and remote write drops non-cumulative monotonic sums, so put delta_to_cumulative in front of the exporter:
connectors:
count/esx:
logs:
esxi.events:
description: Parsed ESXi events by type and host
conditions:
- 'log.attributes["esx.event"] != nil'
attributes:
- key: host.name
- key: esx.event
processors:
delta_to_cumulative: {}
service:
pipelines:
logs/esx:
receivers: [syslog/esx_3164, syslog/esx_5424]
processors: [memory_limiter, transform/esx_events]
exporters: [otlp_http/loki, count/esx]
metrics/esx_counts:
receivers: [count/esx]
processors: [delta_to_cumulative]
exporters: [prometheus_remote_write]
Both components are alpha. The result is a counter with host_name and esx_event labels that you can increase() over a window like any other.
09. Correlating logs and metrics by host
Correlation in Grafana is not magic; it is two queries that happen to filter on the same value. The work is making sure the value really is the same on both sides, and that is a collector job:
- Logs: part 3 sets resource
host.namefrom the syslog hostname, lower-cased, in the receiver’s operator chain. - Metrics: the
transform/vsphere_metricsprocessor in section 06 copiesvcenter.host.name, lower-cased, intohost.nameon host resources only (VM and resource pool resources also carryvcenter.host.name, buthost.nameon a VM resource should mean the VM).vcenter.host.nameitself is left untouched so part 2 queries keep working. - The mismatch you will hit: vCenter knows a host by the name it was added with (often the FQDN, sometimes an IP), while the host’s syslog header carries its own configured hostname (sometimes short). Compare
label_values(vcenter_host_cpu_utilization_percent, host_name)withsum by (host_name) (count_over_time({service_name="esxi"}[1h])). If one side is short and the other is an FQDN, uncomment thereplace_patternline in the metrics transform and add the same statement for logs. If hosts were added to vCenter by IP, fix that in vCenter; no regex will.
Once the names agree, these pairs answer real questions:
# Which hosts logged APD or PDL in the last hour, and what was their device latency?
sum by (host_name) (count_over_time({service_name="esxi"} | esx_event=~"apd_start|apd_timeout|pdl" [1h]))
max by (host_name, object) (max_over_time(vcenter_host_disk_latency_avg_milliseconds{host_name="esx01.lab.local"}[1h]))
# SCSI errors by device and sense key for one host, next to that device's latency
sum by (storage_device, scsi_sense_key) (count_over_time({service_name="esxi"} | host_name="esx01.lab.local" | esx_event="scsi_error" [15m]))
# NFS disconnects joined to the datastore capacity panel through vcenter_datastore_name
{service_name="esxi"} | esx_event="nfs_disconnect" | vcenter_datastore_name="nfs-ds01"
vcenter_datastore_disk_utilization_percent{vcenter_datastore_name="nfs-ds01"}
For traces, the Loki derived field turns a trace_id in structured metadata into a link to Tempo, and the Tempo data source’s traces-to-logs setting maps the span resource attribute host.name to the Loki field host_name, so a slow span opens the logs from the node that served it. Part 6 walks that path all the way down to datastore latency.
10. Retention, cardinality and sizing
Metric series
Series count, not sample count, is what sizes Prometheus memory. Estimate it per object type from what the receiver emits by default (counts here assume four NICs and eight disk devices per host, two virtual disks and one vNIC per VM, and count each attribute combination):
| Object | Approximate series each | Driven by |
|---|---|---|
| ESXi host | about 100 | Per-device disk metrics (3 metrics, read and write) and per-NIC network metrics (5 metrics, two directions) |
| VM | about 30 to 40 | Per-virtual-disk latency and throughput, per-vNIC network |
| Datastore | 3 | Usage (used and available) and utilisation |
| Cluster, resource pool, datacenter | 5 to 15 | Counts and capacity |
A worked example: 40 hosts, 1,500 VMs and 60 datastores is roughly 4,000 + 52,500 + 180, call it 60,000 active series. At a 2 minute collection interval that is only about 500 samples per second, which a single Prometheus handles easily; memory is driven by the 60,000 series and their label sets. VM churn matters more than VM count: every VM created and deleted leaves its series in the TSDB until retention expires, so a VDI or CI estate with heavy churn needs head room. Measure, do not estimate, once data flows:
# Total vCenter series and the ten biggest metric names
count({__name__=~"vcenter_.+"})
topk(10, count by (__name__) ({__name__=~"vcenter_.+"}))
# Which promoted label is exploding?
count by (vcenter_cluster_name) (vcenter_vm_cpu_readiness_percent)
# Prometheus's own view
prometheus_tsdb_head_series
The two levers if it grows too fast: disable metrics you do not chart in the receiver’s metrics: block (per-NIC packet rates are the usual candidates), and promote fewer resource attributes. vcenter.vm.id is a UUID and adds nothing to series count because it is one per VM, but promoting both it and vcenter.vm.name doubles the label payload of every VM series for no query benefit. Beyond a few hundred thousand series, or when you need more than a month, move to Mimir: the collector change is one exporter endpoint.
Log volume
ESXi log volume varies by an order of magnitude between a quiet host and one with a flapping path, so measure it from the collector: sum(rate(otelcol_receiver_accepted_log_records[5m])) for records per second, and in Loki sum by (host_name) (bytes_over_time({service_name="esxi"}[1h])) for bytes per host. The arithmetic for capacity is simple: a host averaging 5 lines per second at 250 bytes writes about 108 MB of raw log a day, so 40 such hosts is about 4.3 GB a day before Loki’s chunk compression. Size the disk from your measured rate times retention, then let the compression be your margin rather than your plan.
Cardinality in Loki
Loki cost is driven by the number of streams, which is the number of distinct index label combinations. This build has service_name, service_namespace and host_name for ESXi, so streams equal hosts. Everything else from part 3 (esx_event, storage_device, scsi_*, vsphere_op_id) is structured metadata, which is the right place for high-cardinality fields: filterable, cheap to store, no stream explosion. Loki’s defaults cap structured metadata per line in both size and entry count, which the part 3 records stay well inside.
Retention defaults in this build
| Store | Retention | Where it is set |
|---|---|---|
| Prometheus | 30 days or 40 GB | --storage.tsdb.retention.time and .size in compose.yaml |
| Loki | 30 days, ESXi logs 90 days | limits_config.retention_period and retention_stream |
| Tempo | 7 days | overrides.defaults.compaction.block_retention |
| Collector queue | Until delivered or 5 minutes of retries (exporter default) | retry_on_failure and sending_queue per exporter |
As a lab starting point the whole stack runs on one VM with 4 vCPU, 16 GB RAM and 200 GB of disk for an estate of the size in the worked example. Treat those numbers as a place to start measuring from. Sizing the OTel collector for vSphere covers the collector side in depth.
11. End-to-end workflow
- Prepare the VM: any Linux VM with Docker Engine and the Compose plugin, or Podman 4+ with
podman compose. Check:docker compose version. Expected: a version string, no error. - Create the directory and files from section 06 and 07, replace
<VCENTER_FQDN>, create.envandchmod 600 .env. Check:docker compose config --quiet. Expected: no output (the file parses and variables resolve). - Validate the collector configuration before starting anything:
docker run --rm --env-file .env -v "$PWD/otelcol/config.yaml:/c.yaml:ro" otel/opentelemetry-collector-contrib:0.166.0 validate --config=/c.yaml. Expected: no output, exit code 0. - Start the stack:
docker compose up -d. Check:docker compose ps. Expected: five services in staterunning. - Check each backend is ready:
curl -s localhost:9090/-/ready,curl -s localhost:3100/ready,curl -s localhost:3200/ready,curl -s localhost:13133. Expected: Prometheus and Loki and Tempo report ready (Loki may say not ready for up to a minute after start), the collector returns"Server available". - Confirm vCenter metrics arrive after one collection interval (2 minutes):
curl -s 'localhost:9090/api/v1/query?query=count(vcenter_host_cpu_utilization_percent)' | jq '.data.result[0].value[1]'. Expected: your host count as a string, for example"40". - Confirm the labels are there:
curl -s localhost:9090/api/v1/labels | jq -r '.data[]' | grep -E "^(host_name|vcenter_)". Expected:host_name,vcenter_cluster_name,vcenter_host_name,vcenter_vm_nameand the other promoted attributes. - Point one ESXi host at the collector using the part 3 script or
esxcli system syslog config set --loghost='tcp://<STACK_VM_FQDN>:1514'andesxcli system syslog reload, thenesxcli system syslog mark --message=stack-check. Check:curl -sG localhost:3100/loki/api/v1/query_range --data-urlencode 'query={service_name="esxi"} |= "stack-check"' | jq '.data.result | length'. Expected: a number greater than 0. - Check the host name join: in Grafana (
http://<STACK_VM_FQDN>:3000, useradmin) open the vSphere overview dashboard and pick that host. Expected: CPU and memory panels and the ESXi log panels all show data for the same host. If only the metrics show, the names differ; go to section 09. - Check alerting is loaded: Alerting, Alert rules, folder vSphere. Expected: five rules in state Normal, and “vCenter metrics stopped arriving” goes to Firing within about 15 minutes if you stop the collector (
docker compose stop otelcol), then back to Normal after you start it. Configure a contact point before relying on any of it.
12. Troubleshooting
| Symptom | Likely cause | Check | Fix |
|---|---|---|---|
Collector logs 404 from remote write | Prometheus started without the remote write receiver | docker compose logs otelcol | grep prometheus_remote_write | Add --web.enable-remote-write-receiver |
| Collector warns about a deprecated component name | Old prometheusremotewrite, otlphttp or otlp exporter names copied from an older guide | Collector startup log | Rename to prometheus_remote_write, otlp_http, otlp_grpc |
Metrics exist but have no vcenter_* labels | Resource attributes not promoted; they went to target_info (which this config disables) | curl localhost:9090/api/v1/labels | Set resource_constant_labels.included |
Metric names lack _percent or _milliseconds | Translation strategy without suffixes, set on the exporter or in prometheus.yml | grep translation_strategy in both configs | Use UnderscoreEscapingWithSuffixes everywhere, or change every query |
out of order sample or too old errors | Two collectors writing the same series, or a queue replay older than the window | Prometheus log; collector exporter errors | One writer per series; raise out_of_order_time_window |
| Loki returns 404 or 400 to the collector | Endpoint missing /otlp, or structured metadata disabled, or schema older than v13 | docker compose logs loki | endpoint: http://loki:3100/otlp; allow_structured_metadata: true; schema v13 with tsdb |
ESXi logs show up under unknown_service | service.name missing on the resource | Debug exporter at detailed | Keep the add resource["service.name"] operator from part 3 |
| Loki rejects streams for too many labels | Promoted too many resource attributes | Loki log: label limit | Promote only host.name; leave the rest as structured metadata |
| Dashboard log panels empty, metric panels fine | host_name differs between logs and metrics (case, FQDN versus short) | Compare the two label value lists in section 09 | Normalise with ConvertCase and replace_pattern on both sides |
| Alert annotations render as blanks | $labels expanded as an environment variable by provisioning | Look at the rule in the UI | Write $$labels and $$values in the provisioning file |
| Clicking a trace ID in Loki does nothing | Derived field regex does not match the structured metadata key | Explore, log details: is it trace_id? | matcherType: label, matcherRegex: trace_id, datasourceUid: tempo |
| Traces never reach Tempo | otlp_grpc exporter trying TLS against a plaintext endpoint | Collector log: transport or handshake error | tls.insecure: true inside the Compose network |
| Saw-tooth gaps in vCenter panels | Panel step smaller than the 2 minute collection interval | Query inspector: step | timeInterval: 2m on the data source, or a min interval on the panel |
| Grafana alerts flap on latency | Instant query on a single sample | Rule history | Keep max_over_time or avg_over_time windows of at least five intervals |
What’s next
You now have the whole path: vCenter metrics from part 2 and ESXi logs from part 3 stored, named predictably, and joined in Grafana. Part 5 adds the Kubernetes layer running on those hosts with a DaemonSet and gateway, and part 6 follows one slow request from a trace to the pod, the node VM, the ESXi host and finally datastore latency, using exactly the join keys set up here. If you are weighing this stack against what you already own, VCF Operations versus OpenTelemetry and Grafana compares them honestly, and the original Telegraf-based build is still in wiring Grafana into vCenter.
Collector configurations validated with otelcol-contrib 0.166.0 (otelcol-contrib validate). Metric name translation read from the Prometheus otlptranslator source; Loki, Prometheus and Tempo settings from their current documentation and the Tempo 3.1.1 example configuration. Thresholds and sizing figures are starting points for a lab, not measured results from a production estate.
Leave a Reply