Skip to content

Commit

Permalink
updating readme and e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulkaukuntla committed Oct 25, 2024
1 parent 8555634 commit 02c038f
Show file tree
Hide file tree
Showing 7 changed files with 815 additions and 17 deletions.
2 changes: 1 addition & 1 deletion scaphandre/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To install the Scaphandre check on your host:

### Configuration

Edit the `scaphandre.d/conf.yaml` file in the `conf.d/` folder at the root of your [Agent's configuration directory][10]. See the [sample scaphandre.d/conf.yaml][11] for all available configuration options.
Edit the `scaphandre.d/conf.yaml` file in the `conf.d/` folder at the root of your [Agent's configuration directory][10]. See the [sample scaphandre.d/conf.yaml][11] for all available configuration options. For example, to secure Scaphandre command line tags and prevent sensitive data from being pulled into Datadog, you can use the `exclude_labels` config option.

[Restart the Agent][12] to start sending Scaphandre metrics to Datadog.

Expand Down
2 changes: 2 additions & 0 deletions scaphandre/assets/configuration/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ files:
- template: init_config
options:
- template: init_config/default
template: init_config/openmetrics
- template: instances
options:
- template: instances/default
template: instances/openmetrics
112 changes: 112 additions & 0 deletions scaphandre/datadog_checks/scaphandre/config_models/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@
# ddev -x validate models -s <INTEGRATION_NAME>


def shared_skip_proxy():
return False


def shared_timeout():
return 10


def instance_allow_redirects():
return True


def instance_auth_type():
return 'basic'


def instance_cache_metric_wildcards():
return True


def instance_cache_shared_labels():
return True


def instance_collect_counters_with_distributions():
return False


def instance_collect_histogram_buckets():
return True


def instance_disable_generic_tags():
return False

Expand All @@ -12,5 +44,85 @@ def instance_empty_default_hostname():
return False


def instance_enable_health_service_check():
return True


def instance_histogram_buckets_as_distributions():
return False


def instance_ignore_connection_errors():
return False


def instance_kerberos_auth():
return 'disabled'


def instance_kerberos_delegate():
return False


def instance_kerberos_force_initiate():
return False


def instance_log_requests():
return False


def instance_min_collection_interval():
return 15


def instance_non_cumulative_histogram_buckets():
return False


def instance_persist_connections():
return False


def instance_request_size():
return 16


def instance_skip_proxy():
return False


def instance_tag_by_endpoint():
return True


def instance_telemetry():
return False


def instance_timeout():
return 10


def instance_tls_ignore_warning():
return False


def instance_tls_use_host_header():
return False


def instance_tls_verify():
return True


def instance_use_latest_spec():
return False


def instance_use_legacy_auth_encoding():
return True


def instance_use_process_start_time():
return False
114 changes: 112 additions & 2 deletions scaphandre/datadog_checks/scaphandre/config_models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,36 @@

from __future__ import annotations

from typing import Optional
from types import MappingProxyType
from typing import Any, Optional, Union

from pydantic import BaseModel, ConfigDict, field_validator, model_validator
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator

from datadog_checks.base.utils.functions import identity
from datadog_checks.base.utils.models import validation

from . import defaults, validators


class AuthToken(BaseModel):
model_config = ConfigDict(
arbitrary_types_allowed=True,
frozen=True,
)
reader: Optional[MappingProxyType[str, Any]] = None
writer: Optional[MappingProxyType[str, Any]] = None


class ExtraMetric(BaseModel):
model_config = ConfigDict(
arbitrary_types_allowed=True,
extra='allow',
frozen=True,
)
name: Optional[str] = None
type: Optional[str] = None


class MetricPatterns(BaseModel):
model_config = ConfigDict(
arbitrary_types_allowed=True,
Expand All @@ -24,18 +44,108 @@ class MetricPatterns(BaseModel):
include: Optional[tuple[str, ...]] = None


class Metric(BaseModel):
model_config = ConfigDict(
arbitrary_types_allowed=True,
extra='allow',
frozen=True,
)
name: Optional[str] = None
type: Optional[str] = None


class Proxy(BaseModel):
model_config = ConfigDict(
arbitrary_types_allowed=True,
frozen=True,
)
http: Optional[str] = None
https: Optional[str] = None
no_proxy: Optional[tuple[str, ...]] = None


class ShareLabel(BaseModel):
model_config = ConfigDict(
arbitrary_types_allowed=True,
frozen=True,
)
labels: Optional[tuple[str, ...]] = None
match: Optional[tuple[str, ...]] = None


class InstanceConfig(BaseModel):
model_config = ConfigDict(
validate_default=True,
arbitrary_types_allowed=True,
frozen=True,
)
allow_redirects: Optional[bool] = None
auth_token: Optional[AuthToken] = None
auth_type: Optional[str] = None
aws_host: Optional[str] = None
aws_region: Optional[str] = None
aws_service: Optional[str] = None
cache_metric_wildcards: Optional[bool] = None
cache_shared_labels: Optional[bool] = None
collect_counters_with_distributions: Optional[bool] = None
collect_histogram_buckets: Optional[bool] = None
connect_timeout: Optional[float] = None
disable_generic_tags: Optional[bool] = None
empty_default_hostname: Optional[bool] = None
enable_health_service_check: Optional[bool] = None
exclude_labels: Optional[tuple[str, ...]] = None
exclude_metrics: Optional[tuple[str, ...]] = None
exclude_metrics_by_labels: Optional[MappingProxyType[str, Union[bool, tuple[str, ...]]]] = None
extra_headers: Optional[MappingProxyType[str, Any]] = None
extra_metrics: Optional[tuple[Union[str, MappingProxyType[str, Union[str, ExtraMetric]]], ...]] = None
headers: Optional[MappingProxyType[str, Any]] = None
histogram_buckets_as_distributions: Optional[bool] = None
hostname_format: Optional[str] = None
hostname_label: Optional[str] = None
ignore_connection_errors: Optional[bool] = None
ignore_tags: Optional[tuple[str, ...]] = None
include_labels: Optional[tuple[str, ...]] = None
kerberos_auth: Optional[str] = None
kerberos_cache: Optional[str] = None
kerberos_delegate: Optional[bool] = None
kerberos_force_initiate: Optional[bool] = None
kerberos_hostname: Optional[str] = None
kerberos_keytab: Optional[str] = None
kerberos_principal: Optional[str] = None
log_requests: Optional[bool] = None
metric_patterns: Optional[MetricPatterns] = None
metrics: Optional[tuple[Union[str, MappingProxyType[str, Union[str, Metric]]], ...]] = None
min_collection_interval: Optional[float] = None
namespace: Optional[str] = Field(None, pattern='\\w*')
non_cumulative_histogram_buckets: Optional[bool] = None
ntlm_domain: Optional[str] = None
openmetrics_endpoint: str
password: Optional[str] = None
persist_connections: Optional[bool] = None
proxy: Optional[Proxy] = None
raw_line_filters: Optional[tuple[str, ...]] = None
raw_metric_prefix: Optional[str] = None
read_timeout: Optional[float] = None
rename_labels: Optional[MappingProxyType[str, Any]] = None
request_size: Optional[float] = None
service: Optional[str] = None
share_labels: Optional[MappingProxyType[str, Union[bool, ShareLabel]]] = None
skip_proxy: Optional[bool] = None
tag_by_endpoint: Optional[bool] = None
tags: Optional[tuple[str, ...]] = None
telemetry: Optional[bool] = None
timeout: Optional[float] = None
tls_ca_cert: Optional[str] = None
tls_cert: Optional[str] = None
tls_ignore_warning: Optional[bool] = None
tls_private_key: Optional[str] = None
tls_protocols_allowed: Optional[tuple[str, ...]] = None
tls_use_host_header: Optional[bool] = None
tls_verify: Optional[bool] = None
use_latest_spec: Optional[bool] = None
use_legacy_auth_encoding: Optional[bool] = None
use_process_start_time: Optional[bool] = None
username: Optional[str] = None

@model_validator(mode='before')
def _initial_validation(cls, values):
Expand Down
17 changes: 16 additions & 1 deletion scaphandre/datadog_checks/scaphandre/config_models/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@
from datadog_checks.base.utils.functions import identity
from datadog_checks.base.utils.models import validation

from . import validators
from . import defaults, validators


class Proxy(BaseModel):
model_config = ConfigDict(
arbitrary_types_allowed=True,
frozen=True,
)
http: Optional[str] = None
https: Optional[str] = None
no_proxy: Optional[tuple[str, ...]] = None


class SharedConfig(BaseModel):
Expand All @@ -21,7 +31,10 @@ class SharedConfig(BaseModel):
arbitrary_types_allowed=True,
frozen=True,
)
proxy: Optional[Proxy] = None
service: Optional[str] = None
skip_proxy: Optional[bool] = None
timeout: Optional[float] = None

@model_validator(mode='before')
def _initial_validation(cls, values):
Expand All @@ -33,6 +46,8 @@ def _validate(cls, value, info):
field_name = field.alias or info.field_name
if field_name in info.context['configured_fields']:
value = getattr(validators, f'shared_{info.field_name}', identity)(value, field=field)
else:
value = getattr(defaults, f'shared_{info.field_name}', lambda: value)()

return validation.utils.make_immutable(value)

Expand Down
Loading

0 comments on commit 02c038f

Please sign in to comment.