src/platform/packages/shared/kbn-otel-semantic-conventions/README.md
OpenTelemetry semantic conventions processor and field metadata generator for Kibana's Field Metadata Service.
This package processes OpenTelemetry semantic conventions YAML files and generates structured TypeScript field definitions that can be consumed by Kibana's Field Metadata Service. It transforms raw semantic convention specifications into field metadata with descriptions, types, and examples.
resolved-semconv.yaml files into structured TypeScriptany usageThe package generates a structured field collection:
export const semconvFlat: TSemconvFields = {
'service.name': {
name: 'service.name',
description: 'Logical name of the service.',
type: 'keyword',
example: 'shoppingcart'
},
'http.method': {
name: 'http.method',
description: 'HTTP request method.',
type: 'keyword',
example: 'GET'
},
'metrics.go.memory.used': {
name: 'metrics.go.memory.used',
description: 'Memory used by the Go runtime.',
type: 'double'
}
// ... 953 more field definitions
};
import { semconvFlat } from '@kbn/otel-semantic-conventions';
// Get field metadata
const serviceNameField = semconvFlat['service.name'];
console.log(serviceNameField.description); // "Logical name of the service."
The generated fields are automatically integrated into Kibana's Field Metadata Service and available through the standard API:
// In your plugin
const fieldMetadata = await fieldsMetadataClient.getByName('service.name');
// Returns OpenTelemetry field metadata if not found in other repositories
The package processes two types of semantic convention groups:
Registry Groups (registry.*): Attribute definitions from OpenTelemetry registry
Metric Groups (metric.*): Metric definitions and their attributes
OpenTelemetry types are automatically mapped to Elasticsearch field types:
| OpenTelemetry Type | Elasticsearch Type |
|---|---|
string | keyword |
int | long |
double | double |
boolean | boolean |
enum | keyword |
| Complex objects | keyword (fallback) |
# From Kibana root
node scripts/generate_otel_semconv.js
# From Kibana root
yarn test:jest src/platform/packages/shared/kbn-otel-semantic-conventions
src/platform/packages/shared/kbn-otel-semantic-conventions/
├── assets/
│ └── resolved-semconv.yaml # Input YAML from OpenTelemetry
├── src/
│ ├── lib/
│ │ └── generate_semconv.ts # Core processing logic
│ ├── types/
│ │ └── semconv_types.ts # TypeScript definitions
│ ├── generated/
│ │ └── resolved-semconv.ts # Generated field definitions
│ ├── cli.ts # CLI interface
│ └── index.ts # Package exports
├── __tests__/
│ └── generate_semconv.test.ts # Unit tests
├── index.ts # Root exports
├── package.json
├── kibana.jsonc # Package metadata
└── README.md
The package includes GitHub Actions integration for automated maintenance:
otel/weaver for YAML generationWorkflow location: .github/workflows/update-otel-semconv.yml
The generated fields integrate seamlessly with Kibana's existing field metadata infrastructure:
OpenTelemetry fields are used as fallback in this priority order:
The package follows the established repository pattern used by ECS and integration field repositories, providing consistent APIs and performance characteristics.
Field processing logic is in src/lib/generate_semconv.ts. Key functions:
processRegistryGroups(): Handles registry attribute groupsprocessMetricGroups(): Processes metric definitionsmapOtelTypeToEsType(): Converts OpenTelemetry types to Elasticsearch typesextractFirstExample(): Extracts examples from YAML arraysThe package includes comprehensive tests covering:
Run tests with yarn test or from Kibana root:
yarn test:jest src/platform/packages/shared/kbn-otel-semantic-conventions
YAML Processing Errors: Ensure the input resolved-semconv.yaml file is valid and follows the expected structure.
Type Mapping Issues: The package handles unknown OpenTelemetry types by defaulting to keyword. Check console output for mapping warnings.
Generation Failures: Verify file permissions and that the generated/ directory is writable.
Enable verbose logging by running the CLI with debug output:
DEBUG=* node scripts/generate_otel_semconv.js
This package is maintained by the @elastic/obs-onboarding-team. When contributing: