Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Tymchuk authored Sep 15, 2023
2 parents 317161c + 576142a commit e967b94
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 40 deletions.
31 changes: 29 additions & 2 deletions build/ansible/roles/ami-ovf/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,39 @@
enabled: yes
gpgkey: file:///etc/pki/rpm-gpg/PERCONA-PACKAGING-KEY

- name: Disable SELinux
- name: Disable SELinux | EL7
when:
- ansible_distribution == 'CentOS'
- ansible_distribution_major_version == '7'
selinux:
policy: targeted
state: permissive

- name: PMM | Add firewalld rule
- name: Disable SELinux | EL9
when:
- ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- ansible_distribution_major_version == '9'
vars:
ansible_python_interpreter: /usr/bin/python3.9
selinux:
policy: targeted
state: permissive

- name: Add firewalld rule | EL7
when:
- ansible_distribution == 'CentOS'
- ansible_distribution_major_version == '7'
firewalld: port={{ item }} permanent=true state=enabled immediate=yes
with_items:
- 80/tcp
- 443/tcp

- name: Add firewalld rule | EL9
when:
- ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- ansible_distribution_major_version == '9'
vars:
ansible_python_interpreter: /usr/bin/python3.9
firewalld: port={{ item }} permanent=true state=enabled immediate=yes
with_items:
- 80/tcp
Expand Down
23 changes: 19 additions & 4 deletions build/ansible/roles/cloud-node/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,26 @@
- yum-utils
- cloud-init
- firewalld
- python3-pip
- ansible
- python3-libselinux
- python3-firewall

- name: Firewalld | Start EL7
when:
- ansible_distribution == 'CentOS'
- ansible_distribution_major_version == '7'
- ansible_os_family == 'RedHat'
service:
name: firewalld
state: started
enabled: yes

- name: Firewalld | Start
when: ansible_os_family == 'RedHat'
- name: Firewalld | Start EL9
when:
- ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- ansible_distribution_major_version == '9'
- ansible_os_family == 'RedHat'
vars:
ansible_python_interpreter: /usr/bin/python3.9
service:
name: firewalld
state: started
Expand Down
15 changes: 13 additions & 2 deletions build/ansible/roles/pmm2-images/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,25 @@
state: installed
ignore_errors: True

- name: Packages | Update OS
- name: Packages | Update OS EL7
when:
- ansible_distribution == "CentOS"
- ansible_distribution_major_version == "7"
yum:
name: "*"
state: latest
exclude: "ansible*"
disablerepo: percona-release-x86_64

- name: Packages | Update OS EL9
when:
- ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- ansible_distribution_major_version == '9'
yum:
name: "*"
state: latest
disablerepo: percona-release-x86_64

- name: Packages | Install OS tools for EL7
when:
- ansible_distribution == "CentOS"
Expand All @@ -70,7 +82,6 @@
name:
- python3-pip
- python3.11-pip
- python3.11
- python3.11-psycopg2
- rsync
- libsqlite3x-devel # package does not come pre-installed on EL9
Expand Down
21 changes: 8 additions & 13 deletions build/docker/server/Dockerfile.el9
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,14 @@ EXPOSE 80 443

WORKDIR /opt

# NOTE: Ansible should NOT be installed via yum/dnf
# Read more: https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#pip-install
# RUN microdnf -y install yum && yum -y install python3-pip && \
# yum -y install oracle-epel-release-el9 ansible-core && \
# python3 -m pip install ansible && \
# python3 -m pip install setuptools && \
# yum -y install epel-release

RUN microdnf -y install yum && yum -y install python3-pip && \
yum -y install oracle-epel-release-el9 ansible-core && \
yum -y install epel-release && \
yum -y install glibc-langpack-en && \
yum -y install ansible vi
RUN microdnf -y install epel-release && \
microdnf -y install ansible-core \
ansible-collection-community-general \
ansible-collection-community-postgresql \
ansible-collection-ansible-posix \
glibc-langpack-en \
yum \
vi

COPY RPMS /tmp/RPMS
COPY gitCommit /tmp/gitCommit
Expand Down
1 change: 1 addition & 0 deletions build/packages/rpm/server/SPECS/pmm-dump.spec
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ install -d -p %{buildroot}%{_sbindir}
install -p -m 0755 pmm-dump %{buildroot}%{_sbindir}/pmm-dump

%files
%license LICENSE
%doc README.md
%{_sbindir}/pmm-dump

Expand Down
11 changes: 7 additions & 4 deletions build/packages/rpm/server/SPECS/victoriametrics.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

%global repo VictoriaMetrics
%global provider github.com/VictoriaMetrics/%{repo}
%global commit pmm-6401-v1.93.1
%global commit pmm-6401-v1.93.4

Name: percona-victoriametrics
Version: 1.93.1
Release: 2%{?dist}
Version: 1.93.4
Release: 1%{?dist}
Summary: VictoriaMetrics monitoring solution and time series database
License: Apache-2.0
URL: https://%{provider}
Expand Down Expand Up @@ -43,13 +43,16 @@ install -D -p -m 0755 ./bin/vmalert-pure %{buildroot}%{_sbindir}/vmalert


%files
%copying LICENSE
%license LICENSE
%doc README.md
%{_sbindir}/victoriametrics
%{_sbindir}/vmalert


%changelog
* Thu Sep 14 2023 Alex Tymchuk <[email protected]> - 1.93.4-1
- upgrade victoriametrics to 1.93.4 release

* Fri Sep 1 2023 Nurlan Moldomurov <[email protected]> - 1.93.1-2
- upgrade victoriametrics to 1.93.1 release

Expand Down
3 changes: 2 additions & 1 deletion build/packer/pmm2.el9.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
"inline": [
"sudo yum -y update",
"sudo yum -y install epel-release",
"sudo yum -y install ansible"
"sudo yum -y install ansible-core",
"sudo yum -y install ansible-collection-community-general ansible-collection-community-postgresql ansible-collection-ansible-posix"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions build/scripts/vars
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ docker_client_tarball=${root_dir}/results/docker/pmm2-client-${pmm_version}.dock
source_tarball=${root_dir}/results/source_tarball/pmm2-client-${pmm_version}.tar.gz
binary_tarball=${root_dir}/results/tarball/pmm2-client-${pmm_version}.tar.gz

# https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/pmm-6401-v1.93.1
vmagent_commit_hash=ca20478a69233179b1891755937b5c7d58791fc2
# https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/pmm-6401-v1.93.4
vmagent_commit_hash=58ecb9066574f38f1d1c91ace467316e7f175b09
5 changes: 2 additions & 3 deletions managed/data/iatemplates/agent_down.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ templates:
severity: critical
annotations:
description: |-
PMM agent on node '{{ $labels.node_id }}' cannot be reached. Host may be down.
summary: PMM agent on node '{{ $labels.node_id }}' cannot be reached. Host may be down.

PMM agent on node '{{ $labels.node_name }}', node ID '{{ $labels.node_id }}', cannot be reached. Host may be down.
summary: PMM agent on node '{{ $labels.node_name }}' cannot be reached. Host may be down.
18 changes: 15 additions & 3 deletions managed/services/inventory/inventory_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func NewInventoryMetricsCollector(metrics inventoryMetrics) *InventoryMetricsCol
mAgentsDesc: prom.NewDesc(
prom.BuildFQName(prometheusNamespace, prometheusSubsystem, "agents"),
"Inventory Agent",
[]string{"agent_id", "agent_type", "service_id", "node_id", "pmm_agent_id", "disabled", "version"},
[]string{"agent_id", "agent_type", "service_id", "node_id", "node_name", "pmm_agent_id", "disabled", "version"},
nil),
mNodesDesc: prom.NewDesc(
prom.BuildFQName(prometheusNamespace, prometheusSubsystem, "nodes"),
Expand All @@ -85,7 +85,7 @@ func NewInventoryMetricsCollector(metrics inventoryMetrics) *InventoryMetricsCol
}
}

func GetRunsOnNodeIDByPMMAgentID(agents []*models.Agent, pmmAgentID string) string {
func getRunsOnNodeIDByPMMAgentID(agents []*models.Agent, pmmAgentID string) string {
for _, agent := range agents {
if agent.AgentID == pmmAgentID {
return pointer.GetString(agent.RunsOnNodeID)
Expand All @@ -103,6 +103,16 @@ func (i *InventoryMetrics) GetAgentMetrics(ctx context.Context) ([]Metric, error
return err
}

dbNodes, err := models.FindNodes(tx.Querier, models.NodeFilters{})
if err != nil {
return err
}

nodeMap := make(map[string]string, len(dbNodes))
for _, node := range dbNodes {
nodeMap[node.NodeID] = node.NodeName
}

for _, agent := range dbAgents {
runsOnNodeID := ""
disabled := "0"
Expand All @@ -121,14 +131,16 @@ func (i *InventoryMetrics) GetAgentMetrics(ctx context.Context) ([]Metric, error
runsOnNodeID = pointer.GetString(agent.RunsOnNodeID)
} else {
metricValue = float64(inventorypb.AgentStatus_value[agent.Status])
runsOnNodeID = GetRunsOnNodeIDByPMMAgentID(dbAgents, pmmAgentID)
runsOnNodeID = getRunsOnNodeIDByPMMAgentID(dbAgents, pmmAgentID)
}

nodeName := nodeMap[runsOnNodeID]
agentMetricLabels := []string{
agent.AgentID,
string(agent.AgentType),
pointer.GetString(agent.ServiceID),
runsOnNodeID,
nodeName,
pmmAgentID,
disabled,
pointer.GetString(agent.Version),
Expand Down
8 changes: 4 additions & 4 deletions managed/services/inventory/inventory_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestNewInventoryMetricsCollector(t *testing.T) {

agentMetrics := []Metric{
{
labels: []string{"A1", string(models.PMMAgentType), "S1", "N1", "PA1", strconv.Itoa(1), "V1"},
labels: []string{"A1", string(models.PMMAgentType), "S1", "N1", "NN1", "PA1", strconv.Itoa(1), "V1"},
value: float64(1),
},
}
Expand Down Expand Up @@ -87,13 +87,13 @@ func TestNewInventoryMetricsCollector(t *testing.T) {
const expectedAgentMetrics = `
# HELP pmm_managed_inventory_agents Inventory Agent
# TYPE pmm_managed_inventory_agents gauge
pmm_managed_inventory_agents{agent_id="A1",agent_type="pmm-agent",disabled="1",node_id="N1",pmm_agent_id="PA1",service_id="S1",version="V1"} 1
pmm_managed_inventory_agents{agent_id="A1",agent_type="pmm-agent",disabled="1",node_id="N1",node_name="NN1",pmm_agent_id="PA1",service_id="S1",version="V1"} 1
`

const expectedNodeMetrics = `
# HELP pmm_managed_inventory_nodes Inventory Node
# TYPE pmm_managed_inventory_nodes gauge
pmm_managed_inventory_nodes{container_name="C1",node_id="N1",node_name="N1",node_type="generic"} 1
# TYPE pmm_managed_inventory_nodes gauge
pmm_managed_inventory_nodes{container_name="C1",node_id="N1",node_name="N1",node_type="generic"} 1
`

const expectedServiceMetrics = `
Expand Down
42 changes: 40 additions & 2 deletions update/ansible/playbook/tasks/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,21 @@
- name: Wait for pmm-managed
pause: seconds=10

- name: Update system packages
- name: Update system packages EL7
when:
- ansible_distribution == "CentOS"
- ansible_distribution_major_version == "7"
yum:
name: "*"
state: latest
security: yes
exclude:
- nginx*

- name: Updating only select packages
- name: Updating only select packages EL7
when:
- ansible_distribution == "CentOS"
- ansible_distribution_major_version == "7"
yum:
name: "{{ item }}"
state: latest
Expand All @@ -258,6 +264,38 @@
- sshpass
- vi

- name: Remove ansible RPM if installed | EL9
when:
- ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- ansible_distribution_major_version == '9'
yum:
name: ansible
state: absent
ignore_errors: yes

- name: Install ansible-core RPM | EL9
when:
- ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- ansible_distribution_major_version == '9'
yum:
name:
- ansible-core
- ansible-collection-community-general
- ansible-collection-community-postgresql
- ansible-collection-ansible-posix
state: present

- name: Update system packages EL9
when:
- ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- ansible_distribution_major_version == '9'
- not ansible_check_mode
yum:
name: "*"
state: latest
exclude:
- nginx*

- name: Install nginx
include_role:
name: nginx
Expand Down

0 comments on commit e967b94

Please sign in to comment.