-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PLAT-9857] Install otel collector during universe creation, configur…
…e audit logging and basic log export config upload. Summary: This diff establishes base logic for opentelemetry collector deployment on the DB nodes. Also it applies audit logging config via gflags + log export config via otel collector config file. Test Plan: Create universe. Otel collector is not installed by default. Enable yb.universe.otel_collector_enabled key. Create centos7 universe. Otel collector is installed and configured as system scoped systemd service, but is turned off. Create alma8 universe. Otel collector is installed and configured as user scoped systemd service, but is turned off. Configure DataDog telemetry provider via API. Create universe via API with audit logging enabled + log export enabled. Otel collector is installed and running. Logs are sent to DataDog. Reviewers: svarshney, muthu, #yba-api-review! Reviewed By: svarshney, muthu Subscribers: yugaware Differential Revision: https://phorge.dev.yugabyte.com/D28902
- Loading branch information
1 parent
e667f96
commit 18291ef
Showing
36 changed files
with
2,156 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
managed/devops/roles/install_otel_collector/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2023 YugaByte, Inc. and Contributors | ||
# | ||
# Licensed under the Polyform Free Trial License 1.0.0 (the "License"); you | ||
# may not use this file except in compliance with the License. You | ||
# may obtain a copy of the License at | ||
# | ||
# https://github.com/YugaByte/yugabyte-db/blob/master/licenses/POLYFORM-FREE-TRIAL-LICENSE-1.0.0.txt | ||
|
||
yb_home_dir: "/home/{{ user_name }}" | ||
otel_col_dir: "{{ yb_home_dir }}/otel-collector" | ||
otel_col_config_file: "{{ yb_home_dir }}/otel-collector/config.yml" | ||
otel_col_logs_dir: "{{ yb_home_dir }}/otel-collector/logs" | ||
otel_col_psq_dir: "{{ yb_home_dir }}/otel-collector/psq" | ||
otel_col_version: "0.84.0" | ||
otel_col_platform: "linux" | ||
otel_col_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64'}}" |
77 changes: 77 additions & 0 deletions
77
managed/devops/roles/install_otel_collector/tasks/install-otel-col.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
- name: Install OpenTelemetry collector | Set paths part 1 | ||
set_fact: | ||
otel_col_temp_path: "{{ remote_tmp_dir | default('/tmp') }}/otel-collector" | ||
otel_col_package_file: "otelcol-contrib_{{ otel_col_version }}_{{ otel_col_platform }}_{{ otel_col_arch }}.tar.gz" | ||
_mount_points: "{{ mount_points.split(',') }}" | ||
|
||
- name: Install OpenTelemetry collector | Set paths part 2 | ||
set_fact: | ||
otel_col_local_path: "{{ local_package_path }}/{{ otel_col_package_file }}" | ||
_mount_logs_dir: "{{ _mount_points[0] }}/otel-collector/logs" | ||
_mount_psq_dir: "{{ _mount_points[0] }}/otel-collector/psq" | ||
|
||
- name: Install OpenTelemetry collector | Clean up OpenTelemetry collector temp directory | ||
file: | ||
path: "{{ otel_col_temp_path }}" | ||
state: absent | ||
|
||
- name: Install OpenTelemetry collector | Create OpenTelemetry collector temp directory | ||
file: | ||
path: "{{ otel_col_temp_path }}" | ||
state: directory | ||
mode: 0755 | ||
|
||
- name: Install OpenTelemetry collector | Download and uncompress OpenTelemetry collector | ||
unarchive: | ||
src: "{{ otel_col_local_path }}" | ||
dest: "{{ otel_col_temp_path }}" | ||
copy: yes | ||
|
||
- name: Install OpenTelemetry collector | Create OpenTelemetry collector directory | ||
file: | ||
path: "{{ otel_col_dir }}" | ||
state: directory | ||
mode: 0755 | ||
|
||
- name: Install OpenTelemetry collector | Copy unpacked collector files | ||
copy: | ||
src: "{{ otel_col_temp_path }}/" | ||
dest: "{{ otel_col_dir }}" | ||
remote_src: True | ||
|
||
- name: Install OpenTelemetry collector | Ensure otelcol-contrib permissions. | ||
shell: | | ||
chmod -R 755 {{ otel_col_dir }}/otelcol-contrib | ||
- name: Install OpenTelemetry collector | Clean up OpenTelemetry collector temp directory | ||
file: | ||
path: "{{ otel_col_temp_path }}" | ||
state: absent | ||
|
||
- name: Install OpenTelemetry collector | Create OpenTelemetry collector logs directory | ||
file: | ||
path: "{{ _mount_logs_dir }}" | ||
state: directory | ||
mode: 0755 | ||
|
||
- name: Install OpenTelemetry collector | Symlink OpenTelemetry collector logs directory | ||
file: | ||
src: "{{ _mount_logs_dir }}" | ||
dest: "{{ otel_col_logs_dir }}" | ||
mode: 0755 | ||
state: link | ||
force: yes | ||
|
||
- name: Install OpenTelemetry collector | Create OpenTelemetry collector persistent queues directory | ||
file: | ||
path: "{{ _mount_psq_dir }}" | ||
state: directory | ||
mode: 0755 | ||
|
||
- name: Install OpenTelemetry collector | Symlink OpenTelemetry collector persistent queues directory | ||
file: | ||
src: "{{ _mount_psq_dir }}" | ||
dest: "{{ otel_col_psq_dir }}" | ||
mode: 0755 | ||
state: link | ||
force: yes |
19 changes: 19 additions & 0 deletions
19
managed/devops/roles/install_otel_collector/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- assert: | ||
that: | ||
- user_name is defined | ||
- mount_points is defined | ||
|
||
- name: Install OpenTelemetry collector | ||
include: install-otel-col.yml | ||
become: yes | ||
become_method: sudo | ||
become_user: "{{ user_name }}" | ||
|
||
- name: Create OpenTelemetry collector service | ||
include: otel-col-service.yml | ||
|
||
- name: Control OpenTelemetry collector service | ||
include: otel-col-control.yml | ||
become: yes | ||
become_method: sudo | ||
become_user: "{{ user_name }}" |
54 changes: 54 additions & 0 deletions
54
managed/devops/roles/install_otel_collector/tasks/otel-col-control.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
- block: | ||
- name: Control OpenTelemetry collector | Determine system or user scope | ||
stat: | ||
path: /etc/systemd/system/otel-collector.service | ||
register: systemd_system | ||
|
||
- name: Control OpenTelemetry collector | User mode systemd | Stop existing running OpenTelemetry Collector | ||
systemd: | ||
name: otel-collector | ||
state: stopped | ||
enabled: no | ||
scope: user | ||
when: not systemd_system.stat.exists | ||
|
||
- name: Control OpenTelemetry collector | System mode systemd | Stop and disable OpenTelemetry collector | ||
block: | ||
- name: Control OpenTelemetry collector | System mode systemd | Stop existing running OpenTelemetry collector | ||
shell: | ||
cmd: "sudo systemctl stop otel-collector" | ||
|
||
- name: Control OpenTelemetry collector | System mode systemd | Stop existing running OpenTelemetry collector | ||
shell: | ||
cmd: "sudo systemctl disable otel-collector" | ||
when: systemd_system.stat.exists | ||
|
||
- name: Control OpenTelemetry collector | Remove existing OpenTelemetry collector conf file | ||
file: | ||
path: "{{ otel_col_config_file }}" | ||
state: absent | ||
|
||
- name: Control OpenTelemetry collector | Download new OpenTelemetry collector conf file | ||
copy: | ||
src: "{{ otel_col_config_file_local }}" | ||
dest: "{{ otel_col_config_file }}" | ||
when: otel_col_config_file_local is defined | ||
|
||
- name: Control OpenTelemetry collector | User mode systemd | Enable and start OpenTelemetry collector | ||
systemd: | ||
name: otel-collector | ||
state: started | ||
enabled: yes | ||
scope: user | ||
when: not systemd_system.stat.exists and otel_col_config_file_local is defined | ||
|
||
- name: Control OpenTelemetry collector | System mode systemd | Enable and start OpenTelemetry collector | ||
block: | ||
- name: Control OpenTelemetry collector | System mode systemd | Enable OpenTelemetry collector service | ||
shell: | ||
cmd: "sudo systemctl enable otel-collector" | ||
|
||
- name: Control OpenTelemetry collector | System mode systemd | Run otel-collector.service to start the OpenTelemetry collector | ||
shell: | ||
cmd: "sudo systemctl start otel-collector" | ||
when: systemd_system.stat.exists and otel_col_config_file_local is defined |
51 changes: 51 additions & 0 deletions
51
managed/devops/roles/install_otel_collector/tasks/otel-col-service.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
- block: | ||
- set_fact: | ||
systemd_dir: "/etc/systemd/system" | ||
|
||
- block: | ||
- set_fact: | ||
systemd_dir: "{{ yb_home_dir }}/.config/systemd/user" | ||
|
||
- name: Add user systemd directory | ||
file: | ||
path: "{{ systemd_dir }}" | ||
state: directory | ||
owner: "{{ user_name }}" | ||
group: "{{ user_name }}" | ||
mode: 0744 | ||
when: ansible_os_family != 'RedHat' or (ansible_distribution_major_version != '7' and not (ansible_distribution == 'Amazon' and ansible_distribution_major_version == '2')) | ||
|
||
# Give yugabyte user sudo access to start/stop/restart otel-collector | ||
- name: OpenTelemetry Collector Service | Add yugabyte sudo user permissions for otel service controls without password | ||
lineinfile: | ||
dest: /etc/sudoers.d/yugabyte-otel-col | ||
line: 'yugabyte ALL=(ALL:ALL) NOPASSWD: /bin/systemctl start otel-collector, | ||
/bin/systemctl stop otel-collector, | ||
/bin/systemctl restart otel-collector, | ||
/bin/systemctl enable otel-collector, | ||
/bin/systemctl disable otel-collector, | ||
/bin/systemctl start otel-collector' | ||
create: yes | ||
state: present | ||
mode: 0440 | ||
validate: 'visudo -cf %s' | ||
|
||
# Adding systemd service file for otel-collector | ||
- name: OpenTelemetry Collector Service | Add otel-collector.service | ||
template: | ||
src: otel-collector.service | ||
dest: "{{ systemd_dir }}/otel-collector.service" | ||
owner: "{{ user_name }}" | ||
group: "{{ user_name }}" | ||
mode: 0644 | ||
|
||
- name: OpenTelemetry Collector Service | System mode systemd | Perform daemon-reload for the new services | ||
shell: | ||
cmd: "sudo systemctl daemon-reload" | ||
when: systemd_dir == "/etc/systemd/system" | ||
|
||
- name: OpenTelemetry Collector Service | User mode systemd | Reload systemd user daemon | ||
systemd: | ||
daemon_reload: yes | ||
scope: user | ||
when: systemd_dir != "/etc/systemd/system" |
37 changes: 37 additions & 0 deletions
37
managed/devops/roles/install_otel_collector/templates/otel-collector.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[Unit] | ||
Description=OpenTelemetry Collector | ||
Requires=network-online.target | ||
After=network.target network-online.target multi-user.target | ||
StartLimitInterval=100 | ||
StartLimitBurst=10 | ||
|
||
[Path] | ||
PathExists={{yb_home_dir}}/otel-collector/otelcol-contrib | ||
PathExists={{yb_home_dir}}/otel-collector/config.yml | ||
|
||
[Service] | ||
{% if ansible_os_family == 'RedHat' and (ansible_distribution_major_version == '7' or (ansible_distribution == 'Amazon' and ansible_distribution_major_version == '2')) %} | ||
User={{ user_name }} | ||
Group={{ user_name }} | ||
{% endif %} | ||
# Start | ||
ExecStart={{yb_home_dir}}/otel-collector/otelcol-contrib \ | ||
--config=file:{{yb_home_dir}}/otel-collector/config.yml | ||
Restart=always | ||
RestartSec=5 | ||
# Stop -> SIGTERM - 10s - SIGKILL (if not stopped) | ||
KillMode=process | ||
TimeoutStopFailureMode=terminate | ||
KillSignal=SIGTERM | ||
TimeoutStopSec=10 | ||
FinalKillSignal=SIGKILL | ||
# Logs | ||
StandardOutput=syslog | ||
StandardError=syslog | ||
# ulimit | ||
LimitCORE=infinity | ||
LimitNOFILE=1048576 | ||
LimitNPROC=12000 | ||
|
||
[Install] | ||
WantedBy=default.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ed/src/main/java/com/yugabyte/yw/commissioner/tasks/upgrade/ModifyAuditLoggingConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) YugaByte, Inc. | ||
|
||
package com.yugabyte.yw.commissioner.tasks.upgrade; | ||
|
||
import com.yugabyte.yw.commissioner.BaseTaskDependencies; | ||
import com.yugabyte.yw.commissioner.UpgradeTaskBase; | ||
import com.yugabyte.yw.commissioner.UserTaskDetails.SubTaskGroupType; | ||
import com.yugabyte.yw.forms.AuditLogConfigParams; | ||
import com.yugabyte.yw.models.helpers.NodeDetails.NodeState; | ||
import javax.inject.Inject; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@EqualsAndHashCode(callSuper = false) | ||
public class ModifyAuditLoggingConfig extends UpgradeTaskBase { | ||
|
||
@Inject | ||
protected ModifyAuditLoggingConfig(BaseTaskDependencies baseTaskDependencies) { | ||
super(baseTaskDependencies); | ||
} | ||
|
||
@Override | ||
protected AuditLogConfigParams taskParams() { | ||
return (AuditLogConfigParams) taskParams; | ||
} | ||
|
||
@Override | ||
public SubTaskGroupType getTaskSubGroupType() { | ||
return SubTaskGroupType.Provisioning; | ||
} | ||
|
||
@Override | ||
public NodeState getNodeState() { | ||
return NodeState.Reprovisioning; | ||
} | ||
|
||
@Override | ||
public void run() {} | ||
|
||
// this class need to implement task to update gflag, | ||
// update otel config + restart otel collector | ||
} |
Oops, something went wrong.