@@ -94,7 +94,8 @@ def post_data_to_splunk_hec(
9494 ir ,
9595 additional_metric_fields ,
9696 server_config ,
97- mib_enricher ,
97+ one_time_flag = one_time_flag ,
98+ mib_enricher = mib_enricher ,
9899 )
99100 else :
100101 logger .debug ("event index - %s" , index ["event_index" ])
@@ -131,6 +132,7 @@ def init_builder_with_common_data(current_time, host, index) -> EventBuilder:
131132 builder .add (EventField .TIME , current_time )
132133 builder .add (EventField .HOST , host )
133134 builder .add (EventField .INDEX , index )
135+ builder .add (EventField .SOURCE , "sc4snmp" )
134136 return builder
135137
136138
@@ -183,13 +185,14 @@ def build_metric_data(
183185 ir : InventoryRecord ,
184186 additional_metric_fields ,
185187 server_config ,
188+ one_time_flag = False ,
186189 mib_enricher = None ,
187190):
188191 json_val = json .loads (variables_binds )
189192 metric_name = json_val ["metric_name" ]
190193 metric_value = json_val ["_value" ]
191194 fields = {
192- "metric_name:" + metric_name : metric_value ,
195+ f "metric_name:{ metric_name } " : metric_value ,
193196 EventField .FREQUENCY .value : ir .frequency_str ,
194197 }
195198 if mib_enricher :
@@ -200,6 +203,10 @@ def build_metric_data(
200203
201204 builder = init_builder_with_common_data (time .time (), host , index )
202205 builder .add (EventField .EVENT , EventType .METRIC .value )
206+ if one_time_flag :
207+ builder .add (EventField .SOURCETYPE , "sc4snmp:metric:walk" )
208+ else :
209+ builder .add (EventField .SOURCETYPE , "sc4snmp:metric" )
203210
204211 extract_additional_properties (fields , metric_name , metric_value , server_config )
205212
0 commit comments