def create_scraper_configuration(self, instance=None):
    '\n        Creates a scraper configuration.\n\n        If instance does not specify a value for a configuration option, the value will default to the `init_config`.\n        Otherwise, the `default_instance` value will be used.\n\n        A default mixin configuration will be returned if there is no instance.\n        '
    if ('openmetrics_endpoint' in instance):
        raise CheckException('The setting `openmetrics_endpoint` is only available for Agent version 7 or later')
    if (instance is None):
        instance = {}
    config = copy.deepcopy(instance)
    endpoint = instance.get('prometheus_url')
    if (instance and (endpoint is None)):
        raise CheckException('You have to define a prometheus_url for each prometheus instance')
    config['prometheus_url'] = endpoint
    namespace = instance.get('namespace')
    if (instance and (namespace is None)):
        if (self.default_namespace is None):
            raise CheckException('You have to define a namespace for each prometheus check')
        namespace = self.default_namespace
    config['namespace'] = namespace
    default_instance = self.default_instances.get(namespace, {})
    metrics_mapper = {}
    metrics = (default_instance.get('metrics', []) + instance.get('metrics', []))
    for metric in metrics:
        if isinstance(metric, string_types):
            metrics_mapper[metric] = metric
        else:
            metrics_mapper.update(metric)
    config['metrics_mapper'] = metrics_mapper
    config['_wildcards_re'] = None
    wildcards = set()
    for metric in config['metrics_mapper']:
        if ('*' in metric):
            wildcards.add(translate(metric))
    if wildcards:
        config['_wildcards_re'] = compile('|'.join(wildcards))
    config['prometheus_metrics_prefix'] = instance.get('prometheus_metrics_prefix', default_instance.get('prometheus_metrics_prefix', ''))
    config['label_joins'] = default_instance.get('label_joins', {})
    config['label_joins'].update(instance.get('label_joins', {}))
    config['_label_mapping'] = {}
    config['_active_label_mapping'] = {}
    config['_watched_labels'] = {}
    config['_dry_run'] = True
    config['ignore_metrics'] = instance.get('ignore_metrics', default_instance.get('ignore_metrics', []))
    config['_ignored_metrics'] = set()
    config['_ignored_re'] = None
    ignored_patterns = set()
    for metric in config['ignore_metrics']:
        if ('*' in metric):
            ignored_patterns.add(translate(metric))
        else:
            config['_ignored_metrics'].add(metric)
    if ignored_patterns:
        config['_ignored_re'] = compile('|'.join(ignored_patterns))
    config['ignore_metrics_by_labels'] = instance.get('ignore_metrics_by_labels', default_instance.get('ignore_metrics_by_labels', {}))
    config['send_histograms_buckets'] = is_affirmative(instance.get('send_histograms_buckets', default_instance.get('send_histograms_buckets', True)))
    config['non_cumulative_buckets'] = is_affirmative(instance.get('non_cumulative_buckets', default_instance.get('non_cumulative_buckets', False)))
    config['send_distribution_buckets'] = is_affirmative(instance.get('send_distribution_buckets', default_instance.get('send_distribution_buckets', False)))
    if (config['send_distribution_buckets'] is True):
        config['non_cumulative_buckets'] = True
    config['send_monotonic_counter'] = is_affirmative(instance.get('send_monotonic_counter', default_instance.get('send_monotonic_counter', True)))
    config['send_monotonic_with_gauge'] = is_affirmative(instance.get('send_monotonic_with_gauge', default_instance.get('send_monotonic_with_gauge', False)))
    config['send_distribution_counts_as_monotonic'] = is_affirmative(instance.get('send_distribution_counts_as_monotonic', default_instance.get('send_distribution_counts_as_monotonic', False)))
    config['send_distribution_sums_as_monotonic'] = is_affirmative(instance.get('send_distribution_sums_as_monotonic', default_instance.get('send_distribution_sums_as_monotonic', False)))
    config['labels_mapper'] = default_instance.get('labels_mapper', {})
    config['labels_mapper'].update(instance.get('labels_mapper', {}))
    config['labels_mapper']['le'] = 'upper_bound'
    config['exclude_labels'] = (default_instance.get('exclude_labels', []) + instance.get('exclude_labels', []))
    config['type_overrides'] = default_instance.get('type_overrides', {})
    config['type_overrides'].update(instance.get('type_overrides', {}))
    config['_type_override_patterns'] = {}
    with_wildcards = set()
    for (metric, type) in iteritems(config['type_overrides']):
        if ('*' in metric):
            config['_type_override_patterns'][compile(translate(metric))] = type
            with_wildcards.add(metric)
    for metric in with_wildcards:
        del config['type_overrides'][metric]
    config['label_to_hostname'] = instance.get('label_to_hostname', default_instance.get('label_to_hostname', None))
    config['label_to_hostname_suffix'] = instance.get('label_to_hostname_suffix', default_instance.get('label_to_hostname_suffix', None))
    config['health_service_check'] = is_affirmative(instance.get('health_service_check', default_instance.get('health_service_check', True)))
    config['ssl_cert'] = instance.get('ssl_cert', default_instance.get('ssl_cert', None))
    config['ssl_private_key'] = instance.get('ssl_private_key', default_instance.get('ssl_private_key', None))
    config['ssl_ca_cert'] = instance.get('ssl_ca_cert', default_instance.get('ssl_ca_cert', None))
    config['ssl_verify'] = is_affirmative(instance.get('ssl_verify', default_instance.get('ssl_verify', True)))
    config['extra_headers'] = default_instance.get('extra_headers', {})
    config['extra_headers'].update(instance.get('extra_headers', {}))
    config['prometheus_timeout'] = instance.get('prometheus_timeout', default_instance.get('prometheus_timeout', 10))
    config['username'] = instance.get('username', default_instance.get('username', None))
    config['password'] = instance.get('password', default_instance.get('password', None))
    config['custom_tags'] = instance.get('tags', [])
    config['_metric_tags'] = []
    config['_text_filter_blacklist'] = []
    config['bearer_token_auth'] = is_affirmative(instance.get('bearer_token_auth', default_instance.get('bearer_token_auth', False)))
    config['bearer_token_path'] = instance.get('bearer_token_path', default_instance.get('bearer_token_path', None))
    config['_bearer_token'] = self._get_bearer_token(config['bearer_token_auth'], config['bearer_token_path'])
    config['telemetry'] = is_affirmative(instance.get('telemetry', default_instance.get('telemetry', False)))
    config['metadata_metric_name'] = instance.get('metadata_metric_name', default_instance.get('metadata_metric_name'))
    config['metadata_label_map'] = instance.get('metadata_label_map', default_instance.get('metadata_label_map', {}))
    config['_default_metric_transformers'] = {}
    if (config['metadata_metric_name'] and config['metadata_label_map']):
        config['_default_metric_transformers'][config['metadata_metric_name']] = self.transform_metadata
    config['_successfully_executed'] = False
    return config
Creates a scraper configuration.

If instance does not specify a value for a configuration option, the value will default to the `init_config`.
Otherwise, the `default_instance` value will be used.

A default mixin configuration will be returned if there is no instance.
def create_scraper_configuration(self, instance=None):
    '\n        Creates a scraper configuration.\n\n        If instance does not specify a value for a configuration option, the value will default to the `init_config`.\n        Otherwise, the `default_instance` value will be used.\n\n        A default mixin configuration will be returned if there is no instance.\n        '
    if ('openmetrics_endpoint' in instance):
        raise CheckException('The setting `openmetrics_endpoint` is only available for Agent version 7 or later')
    if (instance is None):
        instance = {}
    config = copy.deepcopy(instance)
    endpoint = instance.get('prometheus_url')
    if (instance and (endpoint is None)):
        raise CheckException('You have to define a prometheus_url for each prometheus instance')
    config['prometheus_url'] = endpoint
    namespace = instance.get('namespace')
    if (instance and (namespace is None)):
        if (self.default_namespace is None):
            raise CheckException('You have to define a namespace for each prometheus check')
        namespace = self.default_namespace
    config['namespace'] = namespace
    default_instance = self.default_instances.get(namespace, {})
    metrics_mapper = {}
    metrics = (default_instance.get('metrics', []) + instance.get('metrics', []))
    for metric in metrics:
        if isinstance(metric, string_types):
            metrics_mapper[metric] = metric
        else:
            metrics_mapper.update(metric)
    config['metrics_mapper'] = metrics_mapper
    config['_wildcards_re'] = None
    wildcards = set()
    for metric in config['metrics_mapper']:
        if ('*' in metric):
            wildcards.add(translate(metric))
    if wildcards:
        config['_wildcards_re'] = compile('|'.join(wildcards))
    config['prometheus_metrics_prefix'] = instance.get('prometheus_metrics_prefix', default_instance.get('prometheus_metrics_prefix', ))
    config['label_joins'] = default_instance.get('label_joins', {})
    config['label_joins'].update(instance.get('label_joins', {}))
    config['_label_mapping'] = {}
    config['_active_label_mapping'] = {}
    config['_watched_labels'] = {}
    config['_dry_run'] = True
    config['ignore_metrics'] = instance.get('ignore_metrics', default_instance.get('ignore_metrics', []))
    config['_ignored_metrics'] = set()
    config['_ignored_re'] = None
    ignored_patterns = set()
    for metric in config['ignore_metrics']:
        if ('*' in metric):
            ignored_patterns.add(translate(metric))
        else:
            config['_ignored_metrics'].add(metric)
    if ignored_patterns:
        config['_ignored_re'] = compile('|'.join(ignored_patterns))
    config['ignore_metrics_by_labels'] = instance.get('ignore_metrics_by_labels', default_instance.get('ignore_metrics_by_labels', {}))
    config['send_histograms_buckets'] = is_affirmative(instance.get('send_histograms_buckets', default_instance.get('send_histograms_buckets', True)))
    config['non_cumulative_buckets'] = is_affirmative(instance.get('non_cumulative_buckets', default_instance.get('non_cumulative_buckets', False)))
    config['send_distribution_buckets'] = is_affirmative(instance.get('send_distribution_buckets', default_instance.get('send_distribution_buckets', False)))
    if (config['send_distribution_buckets'] is True):
        config['non_cumulative_buckets'] = True
    config['send_monotonic_counter'] = is_affirmative(instance.get('send_monotonic_counter', default_instance.get('send_monotonic_counter', True)))
    config['send_monotonic_with_gauge'] = is_affirmative(instance.get('send_monotonic_with_gauge', default_instance.get('send_monotonic_with_gauge', False)))
    config['send_distribution_counts_as_monotonic'] = is_affirmative(instance.get('send_distribution_counts_as_monotonic', default_instance.get('send_distribution_counts_as_monotonic', False)))
    config['send_distribution_sums_as_monotonic'] = is_affirmative(instance.get('send_distribution_sums_as_monotonic', default_instance.get('send_distribution_sums_as_monotonic', False)))
    config['labels_mapper'] = default_instance.get('labels_mapper', {})
    config['labels_mapper'].update(instance.get('labels_mapper', {}))
    config['labels_mapper']['le'] = 'upper_bound'
    config['exclude_labels'] = (default_instance.get('exclude_labels', []) + instance.get('exclude_labels', []))
    config['type_overrides'] = default_instance.get('type_overrides', {})
    config['type_overrides'].update(instance.get('type_overrides', {}))
    config['_type_override_patterns'] = {}
    with_wildcards = set()
    for (metric, type) in iteritems(config['type_overrides']):
        if ('*' in metric):
            config['_type_override_patterns'][compile(translate(metric))] = type
            with_wildcards.add(metric)
    for metric in with_wildcards:
        del config['type_overrides'][metric]
    config['label_to_hostname'] = instance.get('label_to_hostname', default_instance.get('label_to_hostname', None))
    config['label_to_hostname_suffix'] = instance.get('label_to_hostname_suffix', default_instance.get('label_to_hostname_suffix', None))
    config['health_service_check'] = is_affirmative(instance.get('health_service_check', default_instance.get('health_service_check', True)))
    config['ssl_cert'] = instance.get('ssl_cert', default_instance.get('ssl_cert', None))
    config['ssl_private_key'] = instance.get('ssl_private_key', default_instance.get('ssl_private_key', None))
    config['ssl_ca_cert'] = instance.get('ssl_ca_cert', default_instance.get('ssl_ca_cert', None))
    config['ssl_verify'] = is_affirmative(instance.get('ssl_verify', default_instance.get('ssl_verify', True)))
    config['extra_headers'] = default_instance.get('extra_headers', {})
    config['extra_headers'].update(instance.get('extra_headers', {}))
    config['prometheus_timeout'] = instance.get('prometheus_timeout', default_instance.get('prometheus_timeout', 10))
    config['username'] = instance.get('username', default_instance.get('username', None))
    config['password'] = instance.get('password', default_instance.get('password', None))
    config['custom_tags'] = instance.get('tags', [])
    config['_metric_tags'] = []
    config['_text_filter_blacklist'] = []
    config['bearer_token_auth'] = is_affirmative(instance.get('bearer_token_auth', default_instance.get('bearer_token_auth', False)))
    config['bearer_token_path'] = instance.get('bearer_token_path', default_instance.get('bearer_token_path', None))
    config['_bearer_token'] = self._get_bearer_token(config['bearer_token_auth'], config['bearer_token_path'])
    config['telemetry'] = is_affirmative(instance.get('telemetry', default_instance.get('telemetry', False)))
    config['metadata_metric_name'] = instance.get('metadata_metric_name', default_instance.get('metadata_metric_name'))
    config['metadata_label_map'] = instance.get('metadata_label_map', default_instance.get('metadata_label_map', {}))
    config['_default_metric_transformers'] = {}
    if (config['metadata_metric_name'] and config['metadata_label_map']):
        config['_default_metric_transformers'][config['metadata_metric_name']] = self.transform_metadata
    config['_successfully_executed'] = False
    return config