Skip to content
Snippets Groups Projects
Commit 881c3e96 authored by Robotka István Adrián's avatar Robotka István Adrián
Browse files

Merge branch 'ignore' into 'master'

add ignore option to the job definitions

See merge request !7
parents 8394eb8e 55d1917e
Branches
Tags
1 merge request!7add ignore option to the job definitions
Pipeline #4212 passed with warnings
...@@ -6,7 +6,7 @@ import yaml ...@@ -6,7 +6,7 @@ import yaml
from config import Config from config import Config
from constants import APP_LOG_TAG, TEMPLATE_PREFIX from constants import APP_LOG_TAG, TEMPLATE_PREFIX
from helper import collect_snippets from helper import collect_snippets, check_true
class ConfigBuilder: class ConfigBuilder:
...@@ -24,6 +24,9 @@ class ConfigBuilder: ...@@ -24,6 +24,9 @@ class ConfigBuilder:
self.load_template(job) self.load_template(job)
template = self.substitute_template_field(job, service) template = self.substitute_template_field(job, service)
# store generated prometheus job config # store generated prometheus job config
if 'ignore' in job and check_true(job['ignore']):
job['output_yaml'] = None
else:
job['output_yaml'] = yaml.safe_load(template) job['output_yaml'] = yaml.safe_load(template)
def load_template(self, job): def load_template(self, job):
......
...@@ -59,6 +59,7 @@ class Generator: ...@@ -59,6 +59,7 @@ class Generator:
data = [] data = []
for service in self.config.service_definitions: for service in self.config.service_definitions:
for job in service['scraping']: for job in service['scraping']:
if job['output_yaml'] is not None:
data.append(job['output_yaml']) data.append(job['output_yaml'])
output['scrape_configs'] = yaml.dump( output['scrape_configs'] = yaml.dump(
{'scrape_configs': data}, {'scrape_configs': data},
......
...@@ -18,6 +18,15 @@ def is_snippet_file(file_identifier: str) -> bool: ...@@ -18,6 +18,15 @@ def is_snippet_file(file_identifier: str) -> bool:
return file_identifier.startswith(SNIPPET_PREFIX) return file_identifier.startswith(SNIPPET_PREFIX)
def check_true(s: str) -> bool:
"""Hmm, is it a true-ish string"""
return s.lower() in [
'true', '1', 't', 'y', 'yes', 'yeah', 'yup', 'certainly', 'uh-huh',
'i', 'igen', 'aha', 'ja', 'jaja', 'nosza', 'mibajlehet', 'miért ne', # Hungarian extension
'temp', 'temporary', 'ideiglenesen' # other extension
]
def collect_snippets(templates): def collect_snippets(templates):
"""Get snippets from templates""" """Get snippets from templates"""
snippets = {} snippets = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment