Intégration Slack
Rapport de recherche Datadog : Bilan sur l'adoption de l'informatique sans serveur Rapport : Bilan sur l'adoption de l'informatique sans serveur

Intégration Slack

Configurez votre intégration Datadog/Slack directement via l’API Datadog.

Ajouter des canaux à l'intégration Slack

PUT https://api.datadoghq.eu/api/v1/integration/slackhttps://api.datadoghq.com/api/v1/integration/slack

Présentation

Ajoutez des canaux à votre intégration Datadog/Slack existante. Cette méthode permet de mettre à jour la configuration de votre intégration en remplaçant votre configuration actuelle par la nouvelle, envoyée à votre organisation Datadog.

Requête

Body Data (required)

Corps de requête pour la mise à jour d’une intégration Datadog/Slack existante.

Expand All

Champ

Type

Description

channels

[object]

An array of slack channel configurations.

account [required]

string

Account to which the channel belongs to.

channel_name [required]

string

Your channel name.

transfer_all_user_comments

boolean

To be notified for every comment on a graph, set it to true. If set to False use the @slack-channel_name syntax for comments to be posted to slack.

{
  "channels": [
    {
      "account": "jane.doe",
      "channel_name": "#general",
      "transfer_all_user_comments": false
    }
  ]
}

Réponse

OK

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Curl command
curl -X PUT "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/integration/slack" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{
  "channels": [
    {
      "account": "jane.doe",
      "channel_name": "#general"
    }
  ]
}
EOF

Créer une intégration Slack

POST https://api.datadoghq.eu/api/v1/integration/slackhttps://api.datadoghq.com/api/v1/integration/slack

Présentation

Créez une intégration Datadog/Slack. Une fois créée, ajoutez-y un canal avec l'endpoint Ajouter des canaux à l’intégration Slack. Cette méthode permet de mettre à jour la configuration de votre intégration en ajoutant votre nouvelle configuration à celle déjà existante dans votre organisation Datadog.

Requête

Body Data (required)

Corps de requête pour la création d’une intégration Datadog/Slack.

Expand All

Champ

Type

Description

service_hooks

[object]

The array of service hook objects.

account [required]

string

Your Slack account name.

url [required]

string

Your Slack service hook URL.

{
  "service_hooks": [
    {
      "account": "joe.doe",
      "url": "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
    }
  ]
}

Réponse

OK

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Curl command
curl -X POST "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/integration/slack" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{
  "service_hooks": [
    {
      "account": "joe.doe",
      "url": "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
    }
  ]
}
EOF
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

config= {
    "service_hooks": [
      {
        "account": "Main_Account",
        "url": "https://hooks.slack.com/services/1/1/1"
      },
      {
        "account": "doghouse",
        "url": "https://hooks.slack.com/services/2/2/2"
      }
    ]
  }

dog = Dogapi::Client.new(api_key, app_key)

dog.create_integration('slack', config)

Créer un canal dans une intégration Slack

POST https://api.datadoghq.eu/api/v1/integration/slack/configuration/accounts/{team_name}/channelshttps://api.datadoghq.com/api/v1/integration/slack/configuration/accounts/{team_name}/channels

Présentation

Ajoutez un canal à votre intégration Datadog/Slack.

Arguments

Paramètres du chemin

Nom

Type

Description

team_name [required]

string

Your Slack team name.

Requête

Body Data (required)

Charge utile décrivant le canal Slack à créer

Expand All

Champ

Type

Description

display

object

Configuration options for what is shown in an alert event message.

message

boolean

Show the main body of the alert event.

notified

boolean

Show the list of @-handles in the alert event.

snapshot

boolean

Show the alert event's snapshot image.

tags

boolean

Show the scopes on which the monitor alerted.

name

string

Your channel name.

{
  "display": {
    "message": false,
    "notified": false,
    "snapshot": false,
    "tags": false
  },
  "name": "#general"
}

Réponse

OK

The Slack channel configuration.

Expand All

Champ

Type

Description

display

object

Configuration options for what is shown in an alert event message.

message

boolean

Show the main body of the alert event.

notified

boolean

Show the list of @-handles in the alert event.

snapshot

boolean

Show the alert event's snapshot image.

tags

boolean

Show the scopes on which the monitor alerted.

name

string

Your channel name.

{
  "display": {
    "message": false,
    "notified": false,
    "snapshot": false,
    "tags": false
  },
  "name": "#general"
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Item Not Found

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Path parameters
export team_name="CHANGE_ME"
# Curl command curl -X POST "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/integration/slack/configuration/accounts/${team_name}/channels" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \ -d @- << EOF {} EOF

Supprimer une intégration Slack

DELETE https://api.datadoghq.eu/api/v1/integration/slackhttps://api.datadoghq.com/api/v1/integration/slack

Présentation

Supprimez une intégration Datadog/Slack.

Réponse

OK

Authentication error

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Curl command
curl -X DELETE "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/integration/slack" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

dog.delete_integration('slack')

Récupérer un canal dans une intégration Slack

GET https://api.datadoghq.eu/api/v1/integration/slack/configuration/accounts/{team_name}/channels/{channel_name}https://api.datadoghq.com/api/v1/integration/slack/configuration/accounts/{team_name}/channels/{channel_name}

Présentation

Récupérez un canal configuré pour votre intégration Datadog/Slack.

Arguments

Paramètres du chemin

Nom

Type

Description

team_name [required]

string

Your Slack team name.

channel_name [required]

string

The name of the Slack channel being operated on.

Réponse

OK

The Slack channel configuration.

Expand All

Champ

Type

Description

display

object

Configuration options for what is shown in an alert event message.

message

boolean

Show the main body of the alert event.

notified

boolean

Show the list of @-handles in the alert event.

snapshot

boolean

Show the alert event's snapshot image.

tags

boolean

Show the scopes on which the monitor alerted.

name

string

Your channel name.

{
  "display": {
    "message": false,
    "notified": false,
    "snapshot": false,
    "tags": false
  },
  "name": "#general"
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Item Not Found

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Path parameters
export team_name="CHANGE_ME"
export channel_name="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/integration/slack/configuration/accounts/${team_name}/channels/${channel_name}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"

Récupérer tous les canaux dans une intégration Slack

GET https://api.datadoghq.eu/api/v1/integration/slack/configuration/accounts/{team_name}/channelshttps://api.datadoghq.com/api/v1/integration/slack/configuration/accounts/{team_name}/channels

Présentation

Récupérez la liste de tous les canaux configurés pour votre intégration Datadog/Slack.

Arguments

Paramètres du chemin

Nom

Type

Description

team_name [required]

string

Your Slack team name.

Réponse

OK

A list of configured Slack channels.

Expand All

Champ

Type

Description

display

object

Configuration options for what is shown in an alert event message.

message

boolean

Show the main body of the alert event.

notified

boolean

Show the list of @-handles in the alert event.

snapshot

boolean

Show the alert event's snapshot image.

tags

boolean

Show the scopes on which the monitor alerted.

name

string

Your channel name.

{
  "display": {
    "message": false,
    "notified": false,
    "snapshot": false,
    "tags": false
  },
  "name": "#general"
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Item Not Found

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Path parameters
export team_name="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/integration/slack/configuration/accounts/${team_name}/channels" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"

Récupérer les informations sur une intégration Slack

GET https://api.datadoghq.eu/api/v1/integration/slackhttps://api.datadoghq.com/api/v1/integration/slack

Présentation

Récupérez toutes les informations sur votre intégration Datadog/Slack.

Réponse

OK

Expand All

Champ

Type

Description

No response body

{}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Item Not Found

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Curl command
curl -X GET "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/integration/slack" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

dog.get_integration('slack')

Supprimer un canal dans une intégration Slack

DELETE https://api.datadoghq.eu/api/v1/integration/slack/configuration/accounts/{team_name}/channels/{channel_name}https://api.datadoghq.com/api/v1/integration/slack/configuration/accounts/{team_name}/channels/{channel_name}

Présentation

Supprimez un canal de votre intégration Datadog/Slack.

Arguments

Paramètres du chemin

Nom

Type

Description

team_name [required]

string

Your Slack team name.

channel_name [required]

string

The name of the Slack channel being operated on.

Réponse

The channel was removed successfully.

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Item Not Found

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Path parameters
export team_name="CHANGE_ME"
export channel_name="CHANGE_ME"
# Curl command curl -X DELETE "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/integration/slack/configuration/accounts/${team_name}/channels/${channel_name}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"

Mettre à jour un canal dans une intégration Slack

PATCH https://api.datadoghq.eu/api/v1/integration/slack/configuration/accounts/{team_name}/channels/{channel_name}https://api.datadoghq.com/api/v1/integration/slack/configuration/accounts/{team_name}/channels/{channel_name}

Présentation

Mettez à jour un canal utilisé dans votre intégration Datadog/Slack.

Arguments

Paramètres du chemin

Nom

Type

Description

team_name [required]

string

Your Slack team name.

channel_name [required]

string

The name of the Slack channel being operated on.

Requête

Body Data (required)

Charge utile décrivant les champs et valeurs à mettre à jour.

Expand All

Champ

Type

Description

display

object

Configuration options for what is shown in an alert event message.

message

boolean

Show the main body of the alert event.

notified

boolean

Show the list of @-handles in the alert event.

snapshot

boolean

Show the alert event's snapshot image.

tags

boolean

Show the scopes on which the monitor alerted.

name

string

Your channel name.

{
  "display": {
    "message": false,
    "notified": false,
    "snapshot": false,
    "tags": false
  },
  "name": "#general"
}

Réponse

OK

The Slack channel configuration.

Expand All

Champ

Type

Description

display

object

Configuration options for what is shown in an alert event message.

message

boolean

Show the main body of the alert event.

notified

boolean

Show the list of @-handles in the alert event.

snapshot

boolean

Show the alert event's snapshot image.

tags

boolean

Show the scopes on which the monitor alerted.

name

string

Your channel name.

{
  "display": {
    "message": false,
    "notified": false,
    "snapshot": false,
    "tags": false
  },
  "name": "#general"
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Item Not Found

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Path parameters
export team_name="CHANGE_ME"
export channel_name="CHANGE_ME"
# Curl command curl -X PATCH "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/integration/slack/configuration/accounts/${team_name}/channels/${channel_name}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \ -d @- << EOF {} EOF