Conversation
- agents.proto: add AGENT_TYPE_OTEL_COLLECTOR enum, OtelCollector message, AddOtelCollectorParams, wire into ListAgentsResponse, GetAgentResponse, AddAgentRequest, AddAgentResponse - agents.go: implement sealedAgent() for OtelCollector - types/agent_types.go: add AgentTypeOtelCollector constant and name mapping Note: run 'make gen' from repo root to regenerate .pb.go and JSON client before building managed/admin code that uses these types.
- models: add OtelCollectorType constant; settings: add Otel config (CollectorEnabled, LogsRetentionDays), defaults and getters - converters: ToAPIAgent case for OtelCollectorType - inventory: AddOtelCollector (merge log_file_paths into custom_labels, CreateAgent, request state update) - grpc agents_server: agentTypes map, ListAgents/GetAgent/AddAgent cases for otel_collector Requires 'make gen' (after previous commit) for generated API types.
- otelcollector.go: otelCollectorConfig(row) builds SetStateRequest_AgentProcess with OTLP + optional filelog receivers, batch/memory_limiter, OTLP exporter (server URL/auth from template vars) - state.go: case models.OtelCollectorType -> agentProcesses[id] = otelCollectorConfig(row)
- supervisord: OtelCollectorEnabled param, otel-collector program template (autostart when enabled), skip when disabled - nginx: upstream otel-collector (4318), location /otlp/ with auth_request - otel/schema.go: EnsureOtelSchema, EnsureOtelSchemaFromEnv (PMM_CLICKHOUSE_ADDR) - server: call EnsureOtelSchemaFromEnv in UpdateConfigurations when OTEL enabled
… collector - config: add Paths.OtelCollector, default tools/otelcol-contrib - supervisor: processParams case for AGENT_TYPE_OTEL_COLLECTOR with server_otlp_url, server_auth_b64, server_insecure from server config
- add_otel.go: AddOtelCommand with PMMAgentID (autodetect), log-file-paths, custom-labels; calls Inventory AddAgent with otel_collector body - add.go: register Otel subcommand under add Requires 'make gen' for AddAgentParamsBodyOtelCollector / AddAgentOKBodyOtelCollector.
- datasources.yml: add ClickHouse-OTEL datasource (defaultDatabase: otel) - dev/otel/README.md: architecture, enabling, config, extensibility - dev/otel/TESTING.md: prerequisites, add otel, OTLP, ClickHouse, Grafana
- Added OtelCollector type to the agent inventory, including its properties and validation methods. - Updated API responses and requests to include OtelCollector in ListAgentsResponse, GetAgentResponse, AddAgentRequest, and AddAgentResponse. - Enhanced validation for OtelCollector in AddAgent and GetAgent requests. - Updated JSON schemas to reflect the new OtelCollector structure and properties. This commit requires running 'make gen' to regenerate the necessary API types.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v3 #5102 +/- ##
==========================================
- Coverage 47.76% 47.57% -0.20%
==========================================
Files 410 414 +4
Lines 41967 42177 +210
==========================================
+ Hits 20047 20065 +18
- Misses 19943 20134 +191
- Partials 1977 1978 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Updated the configuration tests in config_test.go to include the OtelCollector path. - Ensured consistency across multiple test cases by adding the OtelCollector property to the relevant structures.
- Updated the supervisor process to use strconv.FormatBool for server_insecure parameter. - Added a new OTEL schema management package to handle ClickHouse database and table creation. - Introduced a new configuration file for the OTEL collector in supervisord. - Enhanced the server package to include the new OTEL schema management. - Made minor formatting adjustments across various files for consistency.
| quoted = append(quoted, fmt.Sprintf("%q", p)) | ||
| } | ||
| } | ||
| if len(quoted) > 0 { |
There was a problem hiding this comment.
[go-consistent] reported by reviewdog 🐶
non-zero length test: use len(s) != 0
managed/services/inventory/agents.go
Outdated
| customLabels[k] = v | ||
| } | ||
| } | ||
| if len(p.LogFilePaths) > 0 { |
There was a problem hiding this comment.
[go-consistent] reported by reviewdog 🐶
non-zero length test: use len(s) != 0
- Updated conditions in otelcollector.go and agents.go to use 'len() != 0' for checking log file paths instead of 'len() > 0' for improved clarity and consistency.
…AddOtelCollector method - Set OtelCollectorEnabledDefault to true in settings.go. - Added nil parameter check in AddOtelCollector method in agents.go. - Updated grpc agents_server to validate parameters for AddOtelCollector request.
- Updated EnsureOtelSchema function to accept a ClickHouse DSN instead of separate address, user, and password parameters. - Introduced default values for ClickHouse user and password. - Modified EnsureOtelSchemaFromEnv to construct the DSN using environment variables for improved flexibility and security. - Updated documentation comments for clarity on DSN format and usage.
- Included the otelcol-contrib binary in the PMM tools directory for both deb and rpm packages. - Updated installation scripts to ensure the binary is downloaded and installed correctly based on the architecture. - Modified testing documentation to reflect the inclusion of otelcol-contrib in the PMM client and server packages.
- Updated the script to dynamically find the otelcol-contrib binary after extraction, enhancing robustness. - Added error handling to ensure the binary is present before proceeding with the copy operation, improving reliability during the build process.
- Introduced a new configuration file for the OTEL collector in `otelconfig.go`, defining the YAML structure for OTLP and filelog receivers, processors, and ClickHouse exporter. - Added comprehensive unit tests in `otelconfig_test.go` to validate the configuration generation and ensure correct YAML structure and content. - Updated the `supervisord.go` to handle writing the OTEL collector configuration to the appropriate directory, enhancing the service's configuration management.
- Created the '/srv/otelcol' directory for otel-collector configuration with appropriate ownership and permissions. - Updated entrypoint script to include 'otelcol' in the directory creation process. - Changed configuration paths in supervisord.go and related files to point to the new '/srv/otelcol' directory, ensuring consistency across the application.
- Introduced a new LogSource message to bind log file paths to parser presets, allowing for more flexible log collection configurations. - Updated AddOtelCollectorParams to include log_sources, deprecating log_file_paths for improved clarity and functionality. - Implemented validation for LogSource to ensure proper path and preset handling. - Enhanced OTEL collector configuration to support per-path presets, improving log parsing capabilities. - Updated related documentation and README to reflect changes in log source management and usage.
- Changed the OTEL exporter name from 'otlp' to 'otlp_http' for clarity in configuration. - Adjusted timestamp layout in the database schema to remove unnecessary precision. - Added a new route for OTLP ingest in the Grafana auth server, allowing viewer access for log and trace pushes.
- Added functionality to retrieve and include resource attributes (agent_id, node_id, service_name) in the OTEL collector configuration for improved log correlation with ClickHouse. - Updated baseOtelConfigYaml to conditionally include a resource processor when resource attributes are present, ensuring logs match VictoriaMetrics labels. - Introduced a new utility function, quoteYAMLAttrValue, for safely quoting YAML attribute values. - Modified the OTEL configuration in supervisord to set the pmm_source attribute for better log context.
- Updated the AddOtelCommand structure to include detailed help descriptions for log sources and parser presets, listing available presets for clarity. - Added new log parser presets for nginx access, nginx error, grafana, pmm-managed, pmm-agent, and postgres to the database schema, improving log parsing capabilities. - Implemented default log sources for the server's OTEL collector, ensuring automatic configuration of log paths and presets. - Refined the OTEL collector configuration to focus on OTLP receiver only, with all log collection handled by pmm-agent using database-driven presets. - Updated related tests to reflect changes in the configuration and ensure proper functionality.
- Updated the UpdateConfiguration method in supervisord to accept an optional otelConfigContent parameter, allowing for dynamic OTEL collector configuration. - Implemented logic in the server to build and pass the OTEL configuration content based on settings, improving flexibility in log collection. - Added new log parser presets for ClickHouse and OTEL collector logs, enhancing log parsing capabilities. - Introduced tests for the new OTEL configuration generation and validation, ensuring proper functionality and integration. - Refactored related code to support the new configuration structure and improve overall maintainability.
- Introduced a new pmm-managed binary file to the project. - Refactored the setup function to utilize server.UpdateConfigurations for OTEL configuration, ensuring proper handling of log sources and avoiding duplicate YAML keys. - Improved logging for configuration updates and error handling during the setup process.
- Modified the main function to initiate a post-setup routine for updating server configurations, improving reliability in configuration management. - Simplified the UpdateConfigurations method by removing retry logic, focusing on immediate error handling and logging for OTEL configuration generation. - Enhanced logging to provide clearer feedback during configuration updates, ensuring better traceability of issues.
Made-with: Cursor
- Updated agentsList function to include Otel Collectors. - Added Otel Collector type to acceptableAgentTypes. - Enhanced AddOtelCommand struct for better handling of Otel Collector configurations. - Minor adjustments in tests to accommodate changes in agent configuration. This commit improves the integration of Otel Collectors into the existing agent management system.
| return nil, errors.WithStack(err) | ||
| } | ||
|
|
||
| return s.(*LogParserPreset), nil |
There was a problem hiding this comment.
🚫 [golangci] reported by reviewdog 🐶
type assertion must be checked (forcetypeassert)
| return nil, errors.WithStack(err) | ||
| } | ||
|
|
||
| return s.(*LogParserPreset), nil |
There was a problem hiding this comment.
🚫 [golangci] reported by reviewdog 🐶
type assertion must be checked (forcetypeassert)
|
|
||
| res := make([]*LogParserPreset, len(structs)) | ||
| for i, s := range structs { | ||
| res[i] = s.(*LogParserPreset) |
There was a problem hiding this comment.
🚫 [golangci] reported by reviewdog 🐶
type assertion must be checked (forcetypeassert)
| yamlContent = buildOtelCollectorConfigYAML(clickhouseAddr, clickhouseUser, clickhousePassword, retentionDays) | ||
| } | ||
|
|
||
| if err := os.MkdirAll(otelCollectorConfigDir, 0o755); err != nil { |
There was a problem hiding this comment.
🚫 [golangci] reported by reviewdog 🐶
G301: Expect directory permissions to be 0750 or less (gosec)
| // AddOtelCommand is used by Kong for CLI flags and commands. | ||
| type AddOtelCommand struct { | ||
| PMMAgentID string `help:"Node ID where pmm-agent runs (default is autodetected)"` | ||
| LogFilePaths []string `name:"log-file-paths" help:"Comma-separated list of log file paths to collect (e.g. /var/log/mysql/error.log). Used with --parser-preset or as raw if --log-sources not set."` |
There was a problem hiding this comment.
🚫 [golangci] reported by reviewdog 🐶
The line is 210 characters long, which exceeds the maximum of 170 characters. (lll)
| ` | ||
|
|
||
| // Build filelog receivers from DefaultServerOtelLogSources and DB presets. | ||
| var filelogReceivers []string |
There was a problem hiding this comment.
🚫 [golangci] reported by reviewdog 🐶
Consider pre-allocating filelogReceivers (prealloc)
| presetYAML[name] = p.OperatorYAML | ||
| } | ||
|
|
||
| var receivers []string |
There was a problem hiding this comment.
🚫 [golangci] reported by reviewdog 🐶
Consider pre-allocating receivers (prealloc)
| } | ||
| } | ||
| } else { | ||
| body.LogFilePaths = cmd.LogFilePaths |
There was a problem hiding this comment.
🚫 [golangci] reported by reviewdog 🐶
SA1019: body.LogFilePaths is deprecated: use log_sources for per-path preset. If log_sources is empty, these are used with preset "raw". (staticcheck)
| trimmed := strings.TrimSpace(line) | ||
| if trimmed != "" && !strings.HasPrefix(trimmed, "#") && !strings.HasPrefix(line, " ") && !strings.HasPrefix(line, "\t") { | ||
| if strings.HasSuffix(trimmed, ":") { | ||
| topLevel = append(topLevel, trimmed) |
There was a problem hiding this comment.
🚫 [golangci] reported by reviewdog 🐶
SA4010: this result of append is never used, except maybe in other appends (staticcheck)
managed/otel/config_test.go
Outdated
|
|
||
| func TestIndentYAML(t *testing.T) { | ||
| t.Run("empty", func(t *testing.T) { | ||
| assert.Equal(t, "", indentYAML("", " ")) |
There was a problem hiding this comment.
🚫 [golangci] reported by reviewdog 🐶
empty: use assert.Empty (testifylint)
Made-with: Cursor
- Introduced `AddEbpfTelemetryCommand` to register an OTEL collector agent with Phase 1 eBPF pipeline labels. - Updated `go.mod` and `go.sum` to include new indirect dependencies for `github.com/cenkalti/backoff/v5` and `go.opentelemetry.io` packages. - Modified `add.go` to include the new eBPF telemetry command in the management commands. - Cleaned up unnecessary whitespace in various files for consistency. This commit enhances telemetry capabilities and ensures the project is up-to-date with the latest dependencies.
…settings - Remove bogus self-imports and nonexistent json/models imports from corrupted go-swagger *_parameters.go files (fixes import cycles and pmm-admin release build). - Fix AddOtelCommand custom labels: ParseKeyValuePair(&cmd.CustomLabels) and pass map to inventory API body. - Add Settings.Otel traces_retention_days and metrics_retention_days with defaults 7 and 90; wire supervisord schema and otel-collector YAML to getters alongside logs retention. - Drop unused EnsureOtelTracesMetricsAndServiceMapTablesFromEnv. - Compile preset name sanitizer regexp once in otelcollector.go. Made-with: Cursor
…release Reject imports of non-existent .../json/models in generated parameters files so Jenkins fails with a clear message if go-swagger output regresses. Made-with: Cursor
- Introduced the OpenTelemetry Collector Contrib version (0.148.0) in the vars file for PMM client/server OTEL integration. - Added a reference link to the corresponding release for clarity. This change enhances the configuration for OpenTelemetry integration.
…orter naming - Changed label key format in `AddEbpfTelemetryCommand` to use underscores instead of dots for compliance with PMM inventory rules. - Updated documentation to reflect the new naming convention for ClickHouse exporters, changing from `clickhouse_logs`, `clickhouse_traces`, and `clickhouse_metrics` to `clickhouse/logs`, `clickhouse/traces`, and `clickhouse/metrics`. - Adjusted related test cases to ensure consistency with the new exporter names. This commit improves clarity and adherence to naming standards in telemetry configurations.
…r OTEL collector management - Removed the legacy `AddOtelCommand` and replaced it with `AddOtelCommandGroup`, which organizes commands for managing the OTEL collector, including logs, eBPF, and traces. - Introduced new commands: `AddOtelEbpfCommand`, `AddOtelLogsCommand`, and `AddOtelTracesCommand` to handle specific functionalities related to the OTEL collector. - Updated the `add.go` file to reflect the new command structure, enhancing clarity and usability for OTEL collector management. This refactor improves the organization of OTEL-related commands, making it easier to manage and extend functionality in the future.
…line configuration - Updated the `baseOtelConfigYaml` function to accept separate parameters for log pipeline receivers and traces/metrics receivers, enhancing clarity and flexibility in configuration. - Adjusted calls to `baseOtelConfigYaml` throughout the `otelcollector.go` file to reflect the new parameter structure, ensuring correct receiver assignments for logs, traces, and metrics pipelines. - Improved comments for better understanding of the function's purpose and usage. This refactor streamlines the configuration process for the OpenTelemetry collector, making it easier to manage different types of receivers.
- Added TODO comments in `add_otel_group.go` and `remove.go` to indicate the planned implementation of the `pmm-admin remove otel` command for symmetric management of the OTEL collector. - Clarified current removal process for OTEL collectors via inventory, enhancing documentation for future development. This update sets the stage for improved OTEL command management in upcoming releases.
- Added new messages and RPC methods for managing OTEL log parser presets, including List, Get, Add, Change, and Remove operations. - Updated the server and client interfaces to support these new functionalities. - Enhanced the Swagger and JSON specifications to document the new endpoints for log parser presets. This update improves the management capabilities of OTEL log parser presets, allowing for better customization and usage in the system.
Made-with: Cursor
Restores reproducible builds when go.mod lists indirect OTLP-related modules; fixes missing go.sum entries seen in make release / RPM build. Made-with: Cursor
PMM-0
Link to the Feature Build: SUBMODULES-0
If this PR adds, removes or alters one or more API endpoints, please review and add or update the relevant API documentation as well:
If this PR is related to some other PRs in this or other repositories, please provide links to those PRs: