Quick Start: Export Your First Metrics
Overview
LMC Exporter is a C++ exporter that reads LSEG/LMC shared-memory managed objects and renders app-specific metrics in Prometheus text format.
This quick start shows how to:
- Build the
lmc_exporterexecutable. - Export your first metrics in snapshot mode.
- Run the HTTP metrics endpoint for Prometheus-style scrapes.
The examples use the repository’s built-in ads app mapping and the example shared-memory server key 82. Replace those values with the app and server key used by your LMC environment.
Prerequisites
Before you start, make sure you have:
| Requirement | Notes |
|---|---|
| Linux build environment | Use one of the supported build targets: OL7_64_GCC482, RHEL8_64_GCC831, or RHEL9_64_GCC1141. |
| LMC install tree | The build expects LMC headers and platform libraries, such as include/ and lib/<platform>/.... |
| C++ compiler | The repository configure script prompts for the compiler path. |
| OpenSSL development files | Required for license verification builds. |
make and shell tools | Used to configure and build the executable. |
| Customer license JSON file | Startup requires a valid license file. The public key is embedded by default in the built binary. |
| Accessible LMC shared memory | The exporter must be able to discover a root from the configured server_key. |
How It Works
At startup, lmc_exporter creates a shared-memory server pool, discovers visible root handles, selects the best matching root, subscribes to child objects and variables under that root, and renders matched variables as Prometheus text.
The exporter can render metrics in two first-run modes:
Snapshot mode writes periodic Prometheus-style metric output to stdout. The interval is controlled by --metrics-interval or metrics_interval_seconds.
Use this mode when you want to inspect output directly from a terminal or capture snapshots with a process supervisor.
HTTP metrics mode starts a lightweight listener and serves the rendered Prometheus text on /metrics by default.
Use this mode when Prometheus or another scraper will collect metrics over HTTP.
Build LMC Exporter
From the repository root, configure the build environment:
./configure
The configuration step prompts for values such as:
- LMC install directory
- target platform
- compiler path
- optional
NO_STLmode
Build the executable from src:
cd src
make
If OpenSSL is installed outside the compiler’s default search path, pass the prefix at build time:
make OPENSSL_PREFIX=/path/to/openssl
After a successful build, the executable is available as:
src/lmc_exporter
In NO_STL mode, the output executable is:
src/lmc_exporter_NO_STL
Check the built version:
./src/lmc_exporter --version
Configuration
You can configure the exporter with CLI flags or a TOML file. For quick-start usage, CLI flags are the fastest option.
Required first-run values
| Setting | CLI flag | TOML key | Description |
|---|---|---|---|
| App mapping | --app | app | Selects the metric mapping set. Built-in app values include ads, adh, and ats. |
| Server key | --server-key | server_keys | Shared-memory server key used to discover the target root. Repeat the CLI flag for multiple keys. |
| License file | --license-file | license_file | Path to the customer license JSON file required for startup. |
Optional first-run values
| Setting | CLI flag | TOML key | Description |
|---|---|---|---|
| Instance hint | --instance | instance | Optional root-selection hint. Use a full root ID or a bare instance number when roots follow hostname.instance_no.application naming. |
| Snapshot interval | --metrics-interval | metrics_interval_seconds | Number of seconds between stdout snapshots. |
| Debug logging | --debug | debug | Enables verbose sync, update, and lookup diagnostics. |
| HTTP listener | --enable-metrics-http | metrics_http_enabled | Enables HTTP metrics mode. |
| HTTP bind address | --metrics-bind-address | metrics_bind_address | IPv4 bind address, such as 127.0.0.1 or 0.0.0.0. |
| HTTP port | --metrics-port | metrics_port | HTTP listener port. |
| HTTP path | --metrics-path | metrics_path | Scrape path, usually /metrics. |
Optional TOML quick-start file
Copy the sample TOML file:
cp docs/lmcExporterConfig.toml.sample ./lmcExporterConfig.toml
For a minimal single-target HTTP quick start, use:
context_id = "shmApp"
pool_name = "pool"
app = "ads"
server_keys = ["82"]
metrics_interval_seconds = 10
metrics_http_enabled = true
metrics_bind_address = "127.0.0.1"
metrics_port = 9464
metrics_path = "/metrics"
license_file = "./scratch/example.lic"
Run with the config file:
./src/lmc_exporter --config ./lmcExporterConfig.toml
Usage
Quickstart: Export Your First Metrics
Use a known server key and app mapping. This example uses app ads, server key 82, and a license file at ./scratch/example.lic:
./src/lmc_exporter \
--server-key 82 \
--app ads \
--license-file ./scratch/example.lic
By default, when HTTP mode is not enabled, the exporter writes Prometheus-style snapshots to stdout.
To make root discovery easier to diagnose during a first run, add --debug:
./src/lmc_exporter \
--server-key 82 \
--app ads \
--license-file ./scratch/example.lic \
--debug
If more than one visible root can match the server key, provide an instance hint:
./src/lmc_exporter \
--server-key 82 \
--app ads \
--instance 1 \
--license-file ./scratch/example.lic
The --instance value can be either the full root ID or the bare instance_no segment when roots use hostname.instance_no.application naming.
Running in Snapshot Mode
Snapshot mode is the default mode when the HTTP listener is disabled.
Run a snapshot exporter with a 10-second interval:
./src/lmc_exporter \
--server-key 82 \
--app ads \
--metrics-interval 10 \
--license-file ./scratch/example.lic
The exporter writes Prometheus-style metric snapshots to stdout. Lookup and event diagnostics are written to stderr.
Snapshot mode behavior
- The exporter discovers the root for the configured server key.
- It subscribes to the selected subtree.
- It waits until the tracked subtree is fully subscribed and in sync.
- It periodically writes rendered metrics to
stdout.
Running in HTTP Metrics Mode
HTTP metrics mode serves the same rendered Prometheus output over an HTTP endpoint.
Start the exporter on port 9464:
./src/lmc_exporter \
--server-key 82 \
--app ads \
--enable-metrics-http \
--metrics-bind-address 127.0.0.1 \
--metrics-port 9464 \
--license-file ./scratch/example.lic
Scrape metrics from another shell:
curl "http://127.0.0.1:9464/metrics?server_key=82"
When the HTTP listener is enabled, periodic Prometheus snapshots are no longer written to stdout.
Route by resolved instance
After discovery, you can route by app and resolved instance:
curl "http://127.0.0.1:9464/metrics?app=ads&instance=phoads01.1.ads"
If more than one target shares the same app and instance, include server_key as well:
curl "http://127.0.0.1:9464/metrics?app=ads&instance=phoads01.1.ads&server_key=82"
Use a custom metrics path
Set a custom HTTP path with --metrics-path:
./src/lmc_exporter \
--server-key 82 \
--app ads \
--enable-metrics-http \
--metrics-port 9464 \
--metrics-path /metrics \
--license-file ./scratch/example.lic
Scrape the configured path:
curl "http://127.0.0.1:9464/metrics?server_key=82"
Examples
./src/lmc_exporter \
--server-key 82 \
--app ads \
--metrics-interval 10 \
--license-file ./scratch/example.lic./src/lmc_exporter \
--server-key 82 \
--app ads \
--enable-metrics-http \
--metrics-bind-address 127.0.0.1 \
--metrics-port 9464 \
--license-file ./scratch/example.liccurl "http://127.0.0.1:9464/metrics?server_key=82"context_id = "shmApp"
pool_name = "pool"
app = "ads"
server_keys = ["82"]
metrics_interval_seconds = 10
metrics_http_enabled = true
metrics_bind_address = "127.0.0.1"
metrics_port = 9464
metrics_path = "/metrics"
license_file = "./scratch/example.lic"./src/lmc_exporter --config ./lmcExporterConfig.toml