Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(typha): add new integration #2545

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions typha/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CHANGELOG - Typha

## 1.0.0 / 2024-11-22

***Added***:

* Initial Release

111 changes: 111 additions & 0 deletions typha/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Agent Check: Typha

## Overview

This check monitors [Typha][1] to collect Prometheus metrics through the Datadog Agent.

## Enabling Prometheus metrics

To enable Prometheus metrics, configure the following variables in the `Typha` deployment:

```yaml
TYPHA_PROMETHEUSMETRICSENABLED: "true"
TYPHA_PROMETHEUSMETRICSPORT: "9093"
```

See [Configuring Typha][2] for more information.

## Setup

Follow the instructions below to install and configure this check for an Agent running on a Kubernetes cluster. See also the [Autodiscovery Integration Templates][3] for guidance on applying these instructions.

### Installation

To install the Typha check on your Kubernetes environment, use the following Dockerfile to build an updated version of the Agent that includes the `typha` integration from `integrations-extras`:

```
FROM gcr.io/datadoghq/agent:latest
RUN agent integration install -r -t datadog-typha==<INTEGRATION_VERSION>
```

You can also build the release and use the `.whl` package to install it:

1. Install the [developer toolkit][4].
2. Clone the `integrations-extras` repository:

```shell
git clone https://github.com/DataDog/integrations-extras.git.
```

3. Update your `ddev` config with the `integrations-extras/` path:

```shell
ddev config set extras ./integrations-extras
```

4. To build the `typha` package, run:

```shell
ddev -e release build typha
```
5. Build your Docker image with the integration installed:

```
FROM gcr.io/datadoghq/agent:latest
COPY <WHEEL_PACKAGE_NAME> <DESTINATION>
RUN agent integration install -r -w <DESTINATION>/<WHEEL_PACKAGE_NAME> \
&& rm -rf <DESTINATION>/<WHEEL_PACKAGE_NAME>
```

### Configuration

1. Set `datadog.confd` definition for `typha` integration:

```yaml
typha.yaml: |-
ad_identifiers:
- typha
init_config:
instances:
- prometheus_url: http://%%host%%:9093/metrics
```

2. [Restart the Agent][6].

### Validation

Run the Agent's [status subcommand][5] and look for `typha` under the Checks section.

For a containerized environment, use the following command:

```sh
kubectl exec -it <DATADOG_POD> -n <NAMESPACE> -- agent status
```

## Data Collected

### Metrics

See [metadata.csv][7] for a list of metrics provided by this check.

### Service Checks

See [service_checks.json][8] for a list of service checks provided by this integration.

### Events

Typha does not include any events.

## Troubleshooting

Need help? Contact [Datadog support][9].

[1]: https://docs.tigera.io/calico/latest/reference/typha/
[2]: https://docs.tigera.io/calico/latest/reference/typha/configuration#general-configuration
[3]: https://docs.datadoghq.com/agent/kubernetes/integrations/
[4]: https://docs.datadoghq.com/developers/integrations/python
[5]: https://docs.datadoghq.com/agent/guide/agent-commands/#agent-status-and-information
[6]: https://docs.datadoghq.com/agent/guide/agent-commands/#start-stop-and-restart-the-agent
[7]: https://github.com/DataDog/integrations-extras/blob/master/typha/metadata.csv
[8]: https://github.com/DataDog/integrations-extras/blob/master/typha/assets/service_checks.json
[9]: https://docs.datadoghq.com/help/
18 changes: 18 additions & 0 deletions typha/assets/configuration/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Typha
files:
- name: typha.yaml
options:
- template: init_config
options:
- template: init_config/openmetrics
- template: instances
options:
- name: prometheus_url
required: true
description: The metric endpoint of your Typha instance.
value:
type: string
example: http://%%host%%:9093
- template: instances/openmetrics
overrides:
prometheus_url.value.example: http://%%host%%:9093/metrics
16 changes: 16 additions & 0 deletions typha/assets/service_checks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"agent_version": "7.0.0",
"integration": "Typha",
"check": "typha.prometheus.health",
"statuses": [
"ok",
"critical"
],
"groups": [
"endpoint"
],
"name": "typha prometheus health",
"description": "Returns `CRITICAL` if the Agent fails to connect to the Prometheus metrics endpoint, otherwise `OK`."
}
]
1 change: 1 addition & 0 deletions typha/datadog_checks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
1 change: 1 addition & 0 deletions typha/datadog_checks/typha/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '1.0.0'
4 changes: 4 additions & 0 deletions typha/datadog_checks/typha/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .__about__ import __version__
from .typha import TyphaCheck

__all__ = ['__version__', 'TyphaCheck']
21 changes: 21 additions & 0 deletions typha/datadog_checks/typha/config_models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file is autogenerated.
# To change this file you should edit assets/configuration/spec.yaml and then run the following commands:
# ddev -x validate config -s <INTEGRATION_NAME>
# ddev -x validate models -s <INTEGRATION_NAME>


from .instance import InstanceConfig
from .shared import SharedConfig


class ConfigMixin:
_config_model_instance: InstanceConfig
_config_model_shared: SharedConfig

@property
def config(self) -> InstanceConfig:
return self._config_model_instance

@property
def shared_config(self) -> SharedConfig:
return self._config_model_shared
28 changes: 28 additions & 0 deletions typha/datadog_checks/typha/config_models/defaults.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file is autogenerated.
# To change this file you should edit assets/configuration/spec.yaml and then run the following commands:
# ddev -x validate config -s <INTEGRATION_NAME>
# ddev -x validate models -s <INTEGRATION_NAME>


def instance_empty_default_hostname():
return False


def instance_min_collection_interval():
return 15


def instance_send_distribution_buckets():
return False


def instance_send_distribution_counts_as_monotonic():
return False


def instance_send_distribution_sums_as_monotonic():
return False


def instance_send_histograms_buckets():
return False
53 changes: 53 additions & 0 deletions typha/datadog_checks/typha/config_models/instance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This file is autogenerated.
# To change this file you should edit assets/configuration/spec.yaml and then run the following commands:
# ddev -x validate config -s <INTEGRATION_NAME>
# ddev -x validate models -s <INTEGRATION_NAME>


from __future__ import annotations

from typing import Optional

from pydantic import BaseModel, ConfigDict, 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 InstanceConfig(BaseModel):
model_config = ConfigDict(
validate_default=True,
arbitrary_types_allowed=True,
frozen=True,
)
empty_default_hostname: Optional[bool] = None
min_collection_interval: Optional[float] = None
service: Optional[str] = None
tags: Optional[tuple[str, ...]] = None
prometheus_url: str
prometheus_metrics_prefix: Optional[str] = None
send_distribution_buckets: Optional[bool] = None
send_distribution_counts_as_monotonic: Optional[bool] = None
send_distribution_sums_as_monotonic: Optional[bool] = None
send_histograms_buckets: Optional[bool] = None

@model_validator(mode='before')
def _initial_validation(cls, values):
return validation.core.initialize_config(getattr(validators, 'initialize_instance', identity)(values))

@field_validator('*', mode='before')
def _validate(cls, value, info):
field = cls.model_fields[info.field_name]
field_name = field.alias or info.field_name
if field_name in info.context['configured_fields']:
value = getattr(validators, f'instance_{info.field_name}', identity)(value, field=field)
else:
value = getattr(defaults, f'instance_{info.field_name}', lambda: value)()

return validation.utils.make_immutable(value)

@model_validator(mode='after')
def _final_validation(cls, model):
return validation.core.check_model(getattr(validators, 'check_instance', identity)(model))
44 changes: 44 additions & 0 deletions typha/datadog_checks/typha/config_models/shared.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This file is autogenerated.
# To change this file you should edit assets/configuration/spec.yaml and then run the following commands:
# ddev -x validate config -s <INTEGRATION_NAME>
# ddev -x validate models -s <INTEGRATION_NAME>


from __future__ import annotations

from typing import Optional

from pydantic import BaseModel, ConfigDict, 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 SharedConfig(BaseModel):
model_config = ConfigDict(
validate_default=True,
arbitrary_types_allowed=True,
frozen=True,
)
service: Optional[str] = None

@model_validator(mode='before')
def _initial_validation(cls, values):
return validation.core.initialize_config(getattr(validators, 'initialize_shared', identity)(values))

@field_validator('*', mode='before')
def _validate(cls, value, info):
field = cls.model_fields[info.field_name]
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)

@model_validator(mode='after')
def _final_validation(cls, model):
return validation.core.check_model(getattr(validators, 'check_shared', identity)(model))
9 changes: 9 additions & 0 deletions typha/datadog_checks/typha/config_models/validators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Here you can include additional config validators or transformers
#
# def initialize_instance(values, **kwargs):
# if 'my_option' not in values and 'my_legacy_option' in values:
# values['my_option'] = values['my_legacy_option']
# if values.get('my_number') > 10:
# raise ValueError('my_number max value is 10, got %s' % str(values.get('my_number')))
#
# return values
44 changes: 44 additions & 0 deletions typha/datadog_checks/typha/data/conf.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## All options defined here are available to all instances.
#
init_config:

## @param service - string - optional
## Attach the tag `service:<SERVICE>` to every metric, event, and service check emitted by this integration.
##
## Additionally, this sets the default `service` for every log source.
#
# service: <SERVICE>

## Every instance is scheduled independently of the others.
#
instances:

- prometheus_url: http://%%host%%:9093/metrics
## @param tags - list of strings - optional
## A list of tags to attach to every metric and service check emitted by this instance.
##
## Learn more about tagging at https://docs.datadoghq.com/tagging
#
# tags:
# - <KEY_1>:<VALUE_1>
# - <KEY_2>:<VALUE_2>

## @param service - string - optional
## Attach the tag `service:<SERVICE>` to every metric, event, and service check emitted by this integration.
##
## Overrides any `service` defined in the `init_config` section.
#
# service: <SERVICE>

## @param min_collection_interval - number - optional - default: 15
## This changes the collection interval of the check. For more information, see:
## https://docs.datadoghq.com/developers/write_agent_check/#collection-interval
#
# min_collection_interval: 15

## @param empty_default_hostname - boolean - optional - default: false
## This forces the check to send metrics with no hostname.
##
## This is useful for cluster-level checks.
#
# empty_default_hostname: false
18 changes: 18 additions & 0 deletions typha/datadog_checks/typha/metrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
METRIC_MAP = {
"typha_cache_size": "cache.size",
"typha_snapshots_generated": "snapshots.generated",
"typha_snapshots_reused": "snapshots.reused",
"typha_snapshot_raw_bytes": "snapshot.raw.bytes",
"typha_snapshot_compressed_bytes": "snapshots.compressed.bytes",
"typha_breadcrumb_block": "breadcrumb.block",
"typha_breadcrumb_non_block": "breadcrumb.non.block",
"typha_breadcrumb_seq_number": "breadcrumb.seq.number",
"typha_connections_accepted": "connections.accepted",
"typha_connections_active": "connections.active",
"typha_connections_streaming": "connections.streaming",
"typha_connections_dropped": "connections.dropped",
"typha_log_errors": "log.errors",
"typha_logs_dropped": "logs.dropped",
"typha_updates_skipped": "updates.skipped",
"typha_updates_total": "updates.total",
}
Loading
Loading