https://github.com/concourse/datadog-event-resource
https://github.com/concourse/datadog-event-resource
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/concourse/datadog-event-resource
- Owner: concourse
- License: apache-2.0
- Created: 2016-12-13T00:27:14.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-07-20T17:01:11.000Z (almost 3 years ago)
- Last Synced: 2025-04-21T16:39:11.805Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 939 KB
- Stars: 4
- Watchers: 18
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Datadog Event Resource
Fetch or emit events to Datadog.
## Source Configuration
* `application_key`: *Required.* The application key to use when accessing Datadog.
* `api_key`: *Required.* The api key to use when accessing Datadog.
* `filter`: *Optional.* Regexp to filter events by title when checking.
* `datadog_host`: *Optional.* Datadog host url to switch from US to Europe datacenter, default to US.
## Behavior
### `check`: Listen for events in the event stream from the last 32 days.
Detects new events that have been published to the Datadog event stream within the last 32 days.
### `in`: Fetch an event
Places the following files in the destination:
* `event.json`: The event fetched, as JSON. Example:
```json
{
"date_happened": 1346449298,
"id": 1378859526682864843,
"priority": "normal",
"tags": [
"environment:test"
],
"text": "Oh boy!",
"title": "Did you hear the news today?",
"url": "https://app.datadoghq.com/event/jump_to?event_id=1378859526682864843"
}
```
* `version`: The ID of the event fetched.
#### Parameters
*None.*
### `out`: Emit an event to Datadog
Emits an event based on the static configuration defined in your parameters. Based on the [Datadog API](http://docs.datadoghq.com/api/?lang=console#events-post)
#### Parameters
**Required**
* `title`: The event title. Limited to 100 characters.
One of the following:
* `text`: Static text for the body of the event. Environment variables can be used here to show the build metadata. Please refer to the [Concourse documentation](https://concourse-ci.org/implementing-resource-types.html#resource-metadata) for a list of allowed variables.
* `text_file` Path to a file containing text for the body of the event. This allows the message to be generated by a previous task step in the Concourse job.
Limited to 4000 characters. The text supports markdown.
**Optional**
* `priority`: The priority of the event ('normal' or 'low').
* `host`: Host name to associate with the event.
* `tags`: A list of tags to apply to the event.
* `alert_type`: "error", "warning", "info" or "success".
* `aggregation_key`: An arbitrary string to use for aggregation, max length of 100 characters. If you specify a key, all events using that key will be grouped together in the Event Stream.
* `source_type_name`: The type of event being posted. Options: nagios, hudson, jenkins, user, my apps, feed, chef, puppet, git, bitbucket, fabric, capistrano
## Example Configuration
### Resource
```yaml
resource_types:
- name: datadog-event
type: docker-image
source:
repository: concourse/datadog-event-resource
resources:
- name: datadog-event
type: datadog-event
source:
api_key: API-KEY
application_key: APPLICATION-KEY
filter: "event-.*-regexp"
```
### Plan
```yaml
- get: datadog-event
```
```yaml
- put: datadog-event
params:
title: Did you hear the news today?
text: Oh boy!
priority: normal
tags:
- environment:test
alert_type: info
```
## Development
### Prerequisites
* golang is *required* - version 1.12.x is tested; earlier versions may also
work.
* docker is *required* - version 18.09.x is tested; earlier versions may also
work.
### Running the tests
The tests have been embedded with the `Dockerfile`; ensuring that the testing
environment is consistent across any `docker` enabled platform. When the docker
image builds, the test are run inside the docker container, on failure they
will stop the build.
Run the tests with the following command:
```sh
docker build -t datadog-event-resource --build-arg base_image=concourse/resource-types-base-image-static .
```
### Contributing
Please make all pull requests to the `master` branch and ensure tests pass
locally.
## Caveats
Unless you are planning on using datadog events for triggering jobs, make sure to disable automatic resource checking, like so:
```yaml
resources:
- name: datadog-event
type: datadog-event
check_every: never
source:
api_key: API-KEY
application_key: APPLICATION-KEY
```
And in case you do plan on using datadog events to trigger jobs, make sure you're using event filtering:
```yaml
resources:
- name: datadog-event
type: datadog-event
source:
api_key: API-KEY
application_key: APPLICATION-KEY
filter: "event-.*-regexp"
```
Otherwise you're running a risk of bloating the concourse database if the volume of events going through datadog is high enough.