Skip to content

Add the Teleport Integration #16877

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

Merged
merged 60 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
f065279
initial integration scaffolding
NouemanKHAL Feb 13, 2024
39c0783
add initial setup for integration tests using docker-compose
NouemanKHAL Feb 13, 2024
3fb1a7a
add first integration test
NouemanKHAL Feb 13, 2024
0a05403
critical test pass
NouemanKHAL Feb 13, 2024
9b6992c
add test_connect_ok
NouemanKHAL Feb 13, 2024
57fbd9e
fix test_connect_exception and passing test_connect_ok
NouemanKHAL Feb 13, 2024
e08d530
add test to check common metrics collection
NouemanKHAL Feb 14, 2024
00c9b3d
add metadata.csv
NouemanKHAL Feb 14, 2024
77b9fc0
ddev test teleport -fs
NouemanKHAL Feb 14, 2024
afc8f61
delete some comments
NouemanKHAL Feb 15, 2024
688221b
wip: use openmetrics base class
NouemanKHAL Feb 16, 2024
d98f972
catch main super.check exception, passing -> first two tests
NouemanKHAL Feb 19, 2024
52e2c73
move exception to test to unit tests
NouemanKHAL Feb 21, 2024
a69ac09
add unit tests, setup mocks, fix integration tests
NouemanKHAL Feb 27, 2024
07a4107
assert common metrics in unit tests
NouemanKHAL Feb 27, 2024
d67d762
add metrics fixture
NouemanKHAL Feb 27, 2024
0b2be47
add teleport_cache_stale_events mocks
NouemanKHAL Feb 28, 2024
f6ac1d3
reporting common metrics
NouemanKHAL Feb 28, 2024
db3a851
rename 'version' tag to 'teleport_version'
NouemanKHAL Feb 28, 2024
cc16d1c
format
NouemanKHAL Feb 28, 2024
5818006
remove docker-compose down nothing behavior
NouemanKHAL Feb 28, 2024
04f73f6
update metadata.csv metric names format
NouemanKHAL Feb 28, 2024
deff960
update unit and integration tests to match the new metric names
NouemanKHAL Feb 28, 2024
95e88f0
fix implementation to pass the tests
NouemanKHAL Feb 28, 2024
6a672d5
[PLINT-302] Report Teleport Proxy metrics (#17018)
NouemanKHAL Mar 4, 2024
682b734
Merge remote-tracking branch 'origin/master' into noueman/add-telepor…
NouemanKHAL Mar 4, 2024
5dce18b
[PLINT-303] Report Teleport Auth Service and Backends metrics (#17050)
NouemanKHAL Mar 6, 2024
0cd765b
Refactor and cleanup Teleport Integration (#17084)
NouemanKHAL Mar 13, 2024
b241f86
[PLINT-304] Report metrics for the Teleport SSH Service (#17111)
NouemanKHAL Mar 13, 2024
322cc3f
[PLINT-306] Report metrics for the Teleport Kubernetes Service (#17113)
NouemanKHAL Mar 13, 2024
4874206
[PLINT-305] Report metrics for the Teleport Database Service (#17114)
NouemanKHAL Mar 13, 2024
b12f270
[PLINT-308] Report metrics for the Teleport Enhanced Session Recordin…
NouemanKHAL Mar 13, 2024
e41aece
[PLINT-307] Report metrics for the Teleport internal Prometheus (#17117)
NouemanKHAL Mar 13, 2024
6d02272
[PLINT-326] Add `teleport_service` tag to Teleport metrics (#17216)
NouemanKHAL Mar 20, 2024
f39c299
[PLINT-331] Update `metadata.csv` for the Teleport Integration (#17241)
NouemanKHAL Mar 22, 2024
338eed4
[PLINT-325] Update Teleport Configuration spec (#17261)
NouemanKHAL Mar 22, 2024
9797165
Merge branch 'master' into noueman/add-teleport-integration
NouemanKHAL Apr 3, 2024
122665d
sort metadata.csv
NouemanKHAL Apr 3, 2024
f479d4f
ddev validate ci -s
NouemanKHAL Apr 3, 2024
44e3feb
Merge branch 'master' into noueman/add-teleport-integration
NouemanKHAL Apr 4, 2024
dd59bf3
add DEFAULT_METRIC_LIMIT to fix the openmetrics validation-n
NouemanKHAL Apr 5, 2024
889d463
update classifier_tags
NouemanKHAL Apr 5, 2024
33124fa
add description to the manifest
NouemanKHAL Apr 5, 2024
175e732
fix tile description
NouemanKHAL Apr 5, 2024
8d81e36
update manifest check for metrics
NouemanKHAL Apr 9, 2024
dedfe7b
[WIP] add dashboard
NouemanKHAL Apr 9, 2024
ad2f8b3
add dashboard entry in the manifest.json
NouemanKHAL Apr 9, 2024
d40b947
delele monitors, logs, and saved_views entries from the manifest.json
NouemanKHAL Apr 9, 2024
008913f
remove extra comma in manifest.json
NouemanKHAL Apr 9, 2024
f1a1135
changelog
NouemanKHAL Apr 9, 2024
aaf10dc
Merge branch 'master' into noueman/add-teleport-integration
NouemanKHAL Apr 9, 2024
981445b
ddev validate label --sync
NouemanKHAL Apr 9, 2024
9bfdc06
[PLINT-362] Standardize metric names (#17383)
NouemanKHAL Apr 16, 2024
198a720
Send Teleport service check as a metric (#17441)
NouemanKHAL Apr 25, 2024
fb11765
Update metadata.csv with descriptions and units (#17456)
NouemanKHAL Apr 25, 2024
229dce9
Merge branch 'master' into noueman/add-teleport-integration
NouemanKHAL Apr 25, 2024
8c3dfda
fix manifest.json errors
NouemanKHAL Apr 25, 2024
e56a2a4
update README.md with prerequisites section
NouemanKHAL Apr 25, 2024
1c9fc65
delete dashboard
NouemanKHAL Apr 26, 2024
892dafc
Apply suggestions from code review
NouemanKHAL Apr 26, 2024
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
7 changes: 7 additions & 0 deletions teleport/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# CHANGELOG - Teleport

## 1.0.0 / 2024-02-07

***Added***:

* Initial Release
55 changes: 55 additions & 0 deletions teleport/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Agent Check: Teleport

## Overview

This check monitors [Teleport][1] through the Datadog Agent.

## Setup

Follow the instructions below to install and configure this check for an Agent running on a host. For containerized environments, see the [Autodiscovery Integration Templates][3] for guidance on applying these instructions.

### Installation

The Teleport check is included in the [Datadog Agent][2] package.
No additional installation is needed on your server.

### Configuration

1. Edit the `teleport.d/conf.yaml` file, in the `conf.d/` folder at the root of your Agent's configuration directory to start collecting your teleport performance data. See the [sample teleport.d/conf.yaml][4] for all available configuration options.

2. [Restart the Agent][5].

### Validation

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

## Data Collected

### Metrics

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

### Events

The Teleport integration does not include any events.

### Service Checks

The Teleport integration does not include any service checks.

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

## Troubleshooting

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


[1]: **LINK_TO_INTEGRATION_SITE**
[2]: https://app.datadoghq.com/account/settings/agent/latest
[3]: https://docs.datadoghq.com/agent/kubernetes/integrations/
[4]: https://github.com/DataDog/integrations-core/blob/master/teleport/datadog_checks/teleport/data/conf.yaml.example
[5]: https://docs.datadoghq.com/agent/guide/agent-commands/#start-stop-and-restart-the-agent
[6]: https://docs.datadoghq.com/agent/guide/agent-commands/#agent-status-and-information
[7]: https://github.com/DataDog/integrations-core/blob/master/teleport/metadata.csv
[8]: https://github.com/DataDog/integrations-core/blob/master/teleport/assets/service_checks.json
[9]: https://docs.datadoghq.com/help/
10 changes: 10 additions & 0 deletions teleport/assets/configuration/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Teleport
files:
- name: teleport.yaml
options:
- template: init_config
options:
- template: init_config/default
- template: instances
options:
- template: instances/default
Empty file.
1 change: 1 addition & 0 deletions teleport/assets/service_checks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
4 changes: 4 additions & 0 deletions teleport/datadog_checks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# (C) Datadog, Inc. 2024-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
4 changes: 4 additions & 0 deletions teleport/datadog_checks/teleport/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# (C) Datadog, Inc. 2024-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
__version__ = '1.0.0'
7 changes: 7 additions & 0 deletions teleport/datadog_checks/teleport/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# (C) Datadog, Inc. 2024-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from .__about__ import __version__
from .check import TeleportCheck

__all__ = ['__version__', 'TeleportCheck']
44 changes: 44 additions & 0 deletions teleport/datadog_checks/teleport/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# (C) Datadog, Inc. 2024-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)

from datadog_checks.base import OpenMetricsBaseCheckV2

COMMON_METRICS_MAP = {
'process_state': 'process.state',
'certificate_mismatch': 'certificate_mismatch',
'rx': 'rx',
'server_interactive_sessions_total': 'server_interactive_sessions_total',
'teleport_build_info': 'teleport.build_info',
'teleport_cache_events': 'teleport.cache_events',
'teleport_cache_stale_events': 'teleport.cache_stale_events',
'tx': 'tx',
}

METRIC_MAP = {
**COMMON_METRICS_MAP
}
class TeleportCheck(OpenMetricsBaseCheckV2):
__NAMESPACE__ = 'teleport'

def __init__(self, name, init_config, instances):
super().__init__(name, init_config, instances)
self.check_initializations.appendleft(self._parse_config)

def check(self, _):
try:
super().check(_)
response = self.http.get(self.diagnostic_url + "/healthz")
response.raise_for_status()
self.service_check("health.up", self.OK)
except Exception as e:
self.service_check("health.up", self.CRITICAL, message=str(e))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we separate out the health check, so that if the check raises an exception before we can hit the health endpoint, we don't say the health is critical (we can say it's unknown in that case).

finally:
pass

def _parse_config(self):
self.diagnostic_url = self.instance.get("diagnostic_url")
if self.diagnostic_url:
self.instance.setdefault("openmetrics_endpoint", self.diagnostic_url + "/metrics")
self.instance.setdefault("metrics", [METRIC_MAP])
self.instance.setdefault("rename_labels", {'version': "teleport_version"})
25 changes: 25 additions & 0 deletions teleport/datadog_checks/teleport/config_models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# (C) Datadog, Inc. 2024-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)

# 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
16 changes: 16 additions & 0 deletions teleport/datadog_checks/teleport/config_models/defaults.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# (C) Datadog, Inc. 2024-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)

# 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
51 changes: 51 additions & 0 deletions teleport/datadog_checks/teleport/config_models/instance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# (C) Datadog, Inc. 2024-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)

# 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

@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))
48 changes: 48 additions & 0 deletions teleport/datadog_checks/teleport/config_models/shared.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# (C) Datadog, Inc. 2024-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)

# 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))
13 changes: 13 additions & 0 deletions teleport/datadog_checks/teleport/config_models/validators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# (C) Datadog, Inc. 2024-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)

# 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 teleport/datadog_checks/teleport/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:

-
## @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
4 changes: 4 additions & 0 deletions teleport/hatch.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[env.collectors.datadog-checks]

[[envs.default.matrix]]
python = ["3.11"]
46 changes: 46 additions & 0 deletions teleport/images/IMAGES_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Marketplace Media Carousel Guidelines

## Using the media gallery

To use the media gallery, you must upload a minimum of one image. The gallery
can hold a maximum of 8 pieces of media total, and one of these pieces of media
can be a video (guidelines and submission steps below). Images should be
added to your /images directory and referenced in the manifest.json file.


## Image and video requirements

### Images

```
File type : .jpg or .png
File size : ~500 KB per image, with a max of 1 MB per image
File dimensions : The aspect ratio must be 16:9 minimum, with these constraints:

Width: 1440px
Min height: 810px
Max height: 2560px

File name : Use only letters, numbers, underscores, and hyphens
Color mode : RGB
Color profile : sRGB
Description : 300 characters maximum
```

### Video

To display a video in your media gallery, please send our team the zipped file
or a link to download the video at `marketplace@datadog.com`. In addition,
please upload a thumbnail image for your video as a part of the pull request.
Once approved, we will upload the file to Vimeo and provide you with the
vimeo_id to add to your manifest.json file. Please note that the gallery can
only hold one video.

```
File type : MP4 H.264
File size : Max 1 video; 1 GB maximum size
File dimensions : The aspect ratio must be exactly 16:9, and the resolution must be 1920x1080 or higher
File name : partnerName-appName.mp4
Run time : Recommendation of 60 seconds or less
Description : 300 characters maximum
```
Loading