Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Commit

Permalink
fix: delete index for every scenario without regex
Browse files Browse the repository at this point in the history
  • Loading branch information
omrozowicz-splunk committed Oct 29, 2021
1 parent 25b8203 commit 83da375
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions splunk_connect_for_snmp_poller/manager/hec_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ def extract_additional_properties(fields, metric_name, metric_value, server_conf
for family in oid_families.keys():
if metric_name.startswith("sc4snmp." + family):
stripped = metric_name[: metric_name.index("_")]

input_text = metric_name[metric_name.index("_") + 1 :] # noqa: E203

entries = oid_families[family][enricher_additional_varbinds]
Expand All @@ -226,16 +225,19 @@ def extract_additional_properties(fields, metric_name, metric_value, server_conf

result = re.match(regex, input_text)
if result:
any_regex_matched = True
for index, item in enumerate(names_list):
fields[item] = result.group(index + 1)
del fields["metric_name:" + metric_name]
fields["metric_name:" + stripped] = metric_value
# TODO delete blow debug statement
fields["old_metric_name:" + metric_name] = metric_value
continue
else:
del fields["metric_name:" + metric_name]
fields["metric_name:" + stripped] = metric_value

if not any_regex_matched:
fields["index_number"] = input_text
del fields["metric_name:" + metric_name]
fields["metric_name:" + stripped] = metric_value


def build_error_data(
Expand Down

0 comments on commit 83da375

Please sign in to comment.