{
"path": "prometheus.yml",
"content": (
- "global:"
- " scrape_interval: 15s"
- " evaluation_interval: 15s"
- "alerting:"
- " alertmanagers:"
- " - static_configs:"
- " - targets:"
- "rule_files:"
- "scrape_configs:"
- " - job_name: 'prometheus'"
- " static_configs:"
- " - targets: [{}]".format("")
+ "global:\n"
+ " scrape_interval: 15s\n"
+ " evaluation_interval: 15s\n"
+ "alerting:\n"
+ " alertmanagers:\n"
+ " - static_configs:\n"
+ " - targets:\n"
+ "rule_files:\n"
+ "scrape_configs:\n"
+ " - job_name: 'prometheus'\n"
+ " static_configs:\n"
+ " - targets: [{}]\n".format("")
),
}
],
}
],
"command": [
- "sh",
- "-c",
"/bin/prometheus",
"--config.file=/etc/prometheus/prometheus.yml",
"--storage.tsdb.path=/prometheus",
{
"path": "prometheus.yml",
"content": (
- "global:"
- " scrape_interval: 15s"
- " evaluation_interval: 15s"
- "alerting:"
- " alertmanagers:"
- " - static_configs:"
- " - targets:"
- "rule_files:"
- "scrape_configs:"
- " - job_name: 'prometheus'"
- " static_configs:"
- " - targets: [{}]".format("")
+ "global:\n"
+ " scrape_interval: 15s\n"
+ " evaluation_interval: 15s\n"
+ "alerting:\n"
+ " alertmanagers:\n"
+ " - static_configs:\n"
+ " - targets:\n"
+ "rule_files:\n"
+ "scrape_configs:\n"
+ " - job_name: 'prometheus'\n"
+ " static_configs:\n"
+ " - targets: [{}]\n".format("")
),
}
],
}
],
"command": [
- "sh",
- "-c",
"/bin/prometheus",
"--config.file=/etc/prometheus/prometheus.yml",
"--storage.tsdb.path=/prometheus",
{
"path": "prometheus.yml",
"content": (
- "global:"
- " scrape_interval: 15s"
- " evaluation_interval: 15s"
- "alerting:"
- " alertmanagers:"
- " - static_configs:"
- " - targets:"
- "rule_files:"
- "scrape_configs:"
- " - job_name: 'prometheus'"
- " static_configs:"
- " - targets: [{}]".format("")
+ "global:\n"
+ " scrape_interval: 15s\n"
+ " evaluation_interval: 15s\n"
+ "alerting:\n"
+ " alertmanagers:\n"
+ " - static_configs:\n"
+ " - targets:\n"
+ "rule_files:\n"
+ "scrape_configs:\n"
+ " - job_name: 'prometheus'\n"
+ " static_configs:\n"
+ " - targets: [{}]\n".format("")
),
}
],
}
],
"command": [
- "sh",
- "-c",
"/bin/prometheus",
"--config.file=/etc/prometheus/prometheus.yml",
"--storage.tsdb.path=/prometheus",
{
"path": "prometheus.yml",
"content": (
- "global:"
- " scrape_interval: 15s"
- " evaluation_interval: 15s"
- "alerting:"
- " alertmanagers:"
- " - static_configs:"
- " - targets:"
- "rule_files:"
- "scrape_configs:"
- " - job_name: 'prometheus'"
- " static_configs:"
- " - targets: [{}]".format("")
+ "global:\n"
+ " scrape_interval: 15s\n"
+ " evaluation_interval: 15s\n"
+ "alerting:\n"
+ " alertmanagers:\n"
+ " - static_configs:\n"
+ " - targets:\n"
+ "rule_files:\n"
+ "scrape_configs:\n"
+ " - job_name: 'prometheus'\n"
+ " static_configs:\n"
+ " - targets: [{}]\n".format("")
),
}
],
}
],
"command": [
- "sh",
- "-c",
"/bin/prometheus",
"--config.file=/etc/prometheus/prometheus.yml",
"--storage.tsdb.path=/prometheus",
{
"path": "prometheus.yml",
"content": (
- "global:"
- " scrape_interval: 15s"
- " evaluation_interval: 15s"
- "alerting:"
- " alertmanagers:"
- " - static_configs:"
- " - targets:"
- "rule_files:"
- "scrape_configs:"
- " - job_name: 'prometheus'"
- " static_configs:"
- " - targets: [{}]".format(config["default_target"])
+ "global:\n"
+ " scrape_interval: 15s\n"
+ " evaluation_interval: 15s\n"
+ "alerting:\n"
+ " alertmanagers:\n"
+ " - static_configs:\n"
+ " - targets:\n"
+ "rule_files:\n"
+ "scrape_configs:\n"
+ " - job_name: 'prometheus'\n"
+ " static_configs:\n"
+ " - targets: [{}]\n".format(config["default_target"])
),
}
],
]
pod_envconfig = pod_spec._make_pod_files(config)
-
+ print(expected_result, pod_envconfig)
self.assertListEqual(expected_result, pod_envconfig)
def test_make_readiness_probe(self) -> NoReturn:
}
expected_result = [
- "sh",
- "-c",
"/bin/prometheus",
"--config.file=/etc/prometheus/prometheus.yml",
"--storage.tsdb.path=/prometheus",
self.assertListEqual(expected_result, pod_envconfig)
+ def test_make_pod_command_with_web_admin_api_enabled(self) -> NoReturn:
+ """Testing make pod command."""
+ port = 9090
+ config = {
+ "web_subpath": "/",
+ "default_target": "",
+ "site_url": "",
+ "enable_web_admin_api": True,
+ }
+
+ expected_result = [
+ "/bin/prometheus",
+ "--config.file=/etc/prometheus/prometheus.yml",
+ "--storage.tsdb.path=/prometheus",
+ "--web.console.libraries=/usr/share/prometheus/console_libraries",
+ "--web.console.templates=/usr/share/prometheus/consoles",
+ "--web.route-prefix={}".format(config.get("web_subpath")),
+ "--web.external-url=http://localhost:{}{}".format(
+ port, config.get("web_subpath")
+ ),
+ "--web.enable-admin-api",
+ ]
+
+ pod_envconfig = pod_spec._make_pod_command(config, port)
+
+ self.assertListEqual(expected_result, pod_envconfig)
+
def test_make_pod_spec(self) -> NoReturn:
"""Testing make pod spec."""
image_info = {"upstream-source": "ubuntu/prometheus:latest"}
"web_subpath": "/",
"default_target": "",
"site_url": "",
+ "enable_web_admin_api": False,
}
relation_state = {}
app_name = "prometheus"
{
"path": "prometheus.yml",
"content": (
- "global:"
- " scrape_interval: 15s"
- " evaluation_interval: 15s"
- "alerting:"
- " alertmanagers:"
- " - static_configs:"
- " - targets:"
- "rule_files:"
- "scrape_configs:"
- " - job_name: 'prometheus'"
- " static_configs:"
- " - targets: [{}]".format(
+ "global:\n"
+ " scrape_interval: 15s\n"
+ " evaluation_interval: 15s\n"
+ "alerting:\n"
+ " alertmanagers:\n"
+ " - static_configs:\n"
+ " - targets:\n"
+ "rule_files:\n"
+ "scrape_configs:\n"
+ " - job_name: 'prometheus'\n"
+ " static_configs:\n"
+ " - targets: [{}]\n".format(
config.get("default_target")
)
),
}
],
"command": [
- "sh",
- "-c",
"/bin/prometheus",
"--config.file=/etc/prometheus/prometheus.yml",
"--storage.tsdb.path=/prometheus",
"tls_secret_name": "prometheus",
"max_file_size": 0,
"ingress_whitelist_source_range": "0.0.0.0/0",
+ "enable_web_admin_api": False,
}
relation_state = {}
app_name = "prometheus"
{
"path": "prometheus.yml",
"content": (
- "global:"
- " scrape_interval: 15s"
- " evaluation_interval: 15s"
- "alerting:"
- " alertmanagers:"
- " - static_configs:"
- " - targets:"
- "rule_files:"
- "scrape_configs:"
- " - job_name: 'prometheus'"
- " static_configs:"
- " - targets: [{}]".format(
+ "global:\n"
+ " scrape_interval: 15s\n"
+ " evaluation_interval: 15s\n"
+ "alerting:\n"
+ " alertmanagers:\n"
+ " - static_configs:\n"
+ " - targets:\n"
+ "rule_files:\n"
+ "scrape_configs:\n"
+ " - job_name: 'prometheus'\n"
+ " static_configs:\n"
+ " - targets: [{}]\n".format(
config.get("default_target")
)
),
}
],
"command": [
- "sh",
- "-c",
"/bin/prometheus",
"--config.file=/etc/prometheus/prometheus.yml",
"--storage.tsdb.path=/prometheus",
"web_subpath": "/",
"default_target": "",
"site_url": "",
+ "enable_web_admin_api": False,
}
relation_state = {}
app_name = "prometheus"