def meta_tags(self) -> dict: return { 'source': ['anodot-agent'], 'source_host_id': [self.destination.host_id], 'source_host_name': [tools.replace_illegal_chars(HOSTNAME)], 'pipeline_id': [self.name], 'pipeline_type': [self.source.type] }
def measurement_names_with_target_types(self) -> dict: result = {} measurement_names = self.config.get('measurement_names', {}) for measurement, target_type in self.values.items(): measurement_name = measurement_names.get(measurement, measurement) measurement_name = tools.replace_illegal_chars(measurement_name) result[measurement_name] = target_type return result
def _get_js_vars(self) -> str: return self.DECLARE_VARS_JS.format( required_dimensions=str(self.pipeline.required_dimensions), optional_dimensions=str(self.pipeline.optional_dimensions), measurement_name=tools.replace_illegal_chars( self.pipeline.config.get('measurement_name', {})), target_type=self.pipeline.config.get('target_type', 'gauge'), constant_properties=str(self.pipeline.static_dimensions), host_id=self.pipeline.destination.host_id, host_name=HOSTNAME, pipeline_id=self.pipeline.name, tags=json.dumps(self.pipeline.get_tags()))
def _override_stages(self): super()._override_stages() for stage in self.config['stages']: if stage['instanceName'] == 'transform_records': for conf in stage['configuration']: if conf['name'] == 'stageRequiredFields': conf['value'] = [ '/' + d for d in tools.replace_illegal_chars( self.pipeline.required_dimensions) ] if conf['name'] == 'initScript': conf['value'] = self._get_js_vars()
def count_records_measurement_name(self) -> str: return tools.replace_illegal_chars( self.config.get('count_records_measurement_name', 'count'))
def measurement_names(self) -> list: return [ tools.replace_illegal_chars( self.config.get('measurement_names', {}).get(key, key)) for key in self.values.keys() ]
def dimension_names(self) -> list: return [ tools.replace_illegal_chars(d.replace('/', '_')) for d in self.all_dimensions ]
def static_dimension_names(self) -> list: return [ tools.replace_illegal_chars(s_dim) for s_dim in self.static_dimensions.keys() ]