-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ATMOSPHERE-523] Improve NeutronNetworkOutOfIPs alarm (#2063)
Co-authored-by: Mohammed Naser <[email protected]>
- Loading branch information
Showing
7 changed files
with
149 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright (c) 2024 VEXXHOST, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import json | ||
import os | ||
import shutil | ||
import tempfile | ||
|
||
import rjsonnet | ||
import yaml | ||
|
||
|
||
def import_callback(base, rel): | ||
""" | ||
:param base: The directory containing the code that did the import. | ||
:param rel: The path imported by the code. | ||
""" | ||
path = os.path.join(base, rel) | ||
with open(path, "r") as f: | ||
return path, f.read() | ||
|
||
|
||
def main(): | ||
compiled_string = rjsonnet.evaluate_file( | ||
"roles/kube_prometheus_stack/files/jsonnet/rules.jsonnet", | ||
import_callback=import_callback, | ||
) | ||
compiled = json.loads(compiled_string) | ||
|
||
tempdir = tempfile.mkdtemp() | ||
rule_files = [] | ||
|
||
try: | ||
for rule_file, data in compiled.items(): | ||
file_name = rule_file + ".yml" | ||
path = os.path.join(tempdir, file_name) | ||
|
||
if os.path.exists(path): | ||
raise Exception(f"File {path} already exists") | ||
with open(path, "w") as f: | ||
yaml.dump(data, f) | ||
|
||
rule_files.append(path) | ||
|
||
with open("roles/kube_prometheus_stack/files/jsonnet/tests.yml") as f: | ||
tests = yaml.safe_load(f) | ||
|
||
tests["rule_files"] = rule_files | ||
|
||
tests_file = os.path.join(tempdir, "tests.yml") | ||
with open(tests_file, "w") as f: | ||
yaml.dump(tests, f) | ||
|
||
# TODO(mnaser): Enable JUnit output | ||
os.system(f"promtool test rules {tests_file}") | ||
finally: | ||
shutil.rmtree(tempdir) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright (c) 2024 VEXXHOST, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
tests: | ||
- interval: 1m | ||
input_series: | ||
- series: 'openstack_neutron_network{id="4cf895c9-c3d1-489e-b02e-59b5c8976809",is_external="false",is_shared="false",name="public",provider_network_type="vlan",provider_physical_network="external",provider_segmentation_id="3",status="ACTIVE",subnets="54d6f61d-db07-451c-9ab3-b9609b6b6f0b",tags="tag1,tag2",tenant_id="4fd44f30292945e481c7b8a0c8908869"} 0' | ||
values: '0x360' | ||
- series: 'openstack_neutron_network_ip_availabilities_total{cidr="172.24.4.0/24",ip_version="4",network_id="4cf895c9-c3d1-489e-b02e-59b5c8976809",network_name="public",project_id="1a02cc95f1734fcc9d3c753818f03002",subnet_name="public-subnet"}' | ||
values: '253x360' | ||
- series: 'openstack_neutron_network_ip_availabilities_used{cidr="172.24.4.0/24",ip_version="4",network_id="4cf895c9-c3d1-489e-b02e-59b5c8976809",network_name="public",project_id="1a02cc95f1734fcc9d3c753818f03002",subnet_name="public-subnet"}' | ||
values: '250x360' | ||
alert_rule_test: | ||
- eval_time: 6h | ||
alertname: NeutronNetworkOutOfIPs | ||
exp_alerts: [] | ||
|
||
- interval: 1m | ||
input_series: | ||
- series: 'openstack_neutron_network{id="4cf895c9-c3d1-489e-b02e-59b5c8976809",is_external="true",is_shared="true",name="public",provider_network_type="vlan",provider_physical_network="external",provider_segmentation_id="3",status="ACTIVE",subnets="54d6f61d-db07-451c-9ab3-b9609b6b6f0b",tags="tag1,tag2",tenant_id="4fd44f30292945e481c7b8a0c8908869"} 0' | ||
values: '0x360' | ||
- series: 'openstack_neutron_network_ip_availabilities_total{cidr="172.24.4.0/24",ip_version="4",network_id="4cf895c9-c3d1-489e-b02e-59b5c8976809",network_name="public",project_id="1a02cc95f1734fcc9d3c753818f03002",subnet_name="public-subnet"}' | ||
values: '253x360' | ||
- series: 'openstack_neutron_network_ip_availabilities_used{cidr="172.24.4.0/24",ip_version="4",network_id="4cf895c9-c3d1-489e-b02e-59b5c8976809",network_name="public",project_id="1a02cc95f1734fcc9d3c753818f03002",subnet_name="public-subnet"}' | ||
values: '250x360' | ||
alert_rule_test: | ||
- eval_time: 6h | ||
alertname: NeutronNetworkOutOfIPs | ||
exp_alerts: | ||
- exp_labels: | ||
network_id: 4cf895c9-c3d1-489e-b02e-59b5c8976809 | ||
severity: P3 | ||
exp_annotations: | ||
summary: "[4cf895c9-c3d1-489e-b02e-59b5c8976809] Network running out of IPs" | ||
description: "The network 4cf895c9-c3d1-489e-b02e-59b5c8976809 is currently at 98.81422924901186% utilization. If the IP addresses run out, it will impact the provisioning of new ports." |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) 2024 VEXXHOST, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
- hosts: all | ||
tasks: | ||
- name: Install promtool | ||
block: | ||
- name: Create temporary file to download | ||
ansible.builtin.tempfile: | ||
state: file | ||
suffix: .tar.gz | ||
register: promtool_file | ||
|
||
- name: Download Prometheus | ||
ansible.builtin.get_url: | ||
url: https://github.com/prometheus/prometheus/releases/download/v2.55.0/prometheus-2.55.0.linux-amd64.tar.gz | ||
dest: "{{ promtool_file.path }}" | ||
checksum: sha256:7a6b6d5ea003e8d59def294392c64e28338da627bf760cf268e788d6a8832a23 | ||
|
||
- name: Extract Prometheus into /usr/local/bin | ||
become: true | ||
ansible.builtin.unarchive: | ||
src: "{{ promtool_file.path }}" | ||
dest: /usr/local/bin | ||
remote_src: true | ||
extra_opts: | ||
- --strip-components=1 | ||
include: | ||
- prometheus-2.55.0.linux-amd64/promtool | ||
always: | ||
- name: Remove temporary file | ||
ansible.builtin.file: | ||
path: "{{ promtool_file.path }}" | ||
state: absent |
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