ツナワタリマイライフ

日常ネタから技術ネタ、音楽ネタまで何でも書きます。

Datadog Workflows で OpenAI Integration を試す

こんにちは。この記事は Datadog Advent Calendar 2023 の 12/2 の記事です。

今回は Datadog Workflow で OpenAI Integration を使ってみます。

Datadog Workflow とは

プレスリリースはこちらです。

Monitor, Schedule, Dashboard からの Manual 実行の3種類を Trigger とし、そこからさまざまなことを実行できます。

実行できる内容は Datadog へのさまざまな操作はもちろん、複数の Intergration を使って別のサービスへの操作も可能です。普通に http request を実行することもできるため、Integration のないサービスに対する操作も可能になります。また、javascript もできるのでちょっとしたプログラミングもできてしまいます。

参考

Datadog Workflow の Action

3種類用意されています。インプットに微妙な差異がありますが、ほとんど同じようなものです。

Edit text

Inputs Instruction が以下4つ選択可能です。自由記述も可能です。

  • Improve the text
  • Simplify the text
  • Change the tone to formal
  • Change the tone to informal

Input text に対して何らかの指示を出すための Action です。

Generate text

Inputs Prompt に Prompt を入力するようです。

Edit text との差は明確に Input と Instruction が分かれているかどうかです。

Summarize text

こちらは text to summarize のフィールドに Summerize したい文章を入れることになります。

Edit text で「Summerize the text」を入れた時と同じになる気がしますね。

Blueprints を見てみる

使い心地を見るために、Datadog が提供している Blueprint を見てみましょう。

OpenAI を利用しているのは1つ、「Simplify Language of a Monitor Alert」です。

  • Trigger: Manual
  • Workflow
    • Get event monitor alert details
      • Datadog Event: Get event
      • inputs に event id を入れています
    • Describe the alert message
      • OpenAI Generate text Action
      • Prompt: I have a Datadog monitor message but its in the format intended for the full configuration of the Monitor. So I can't understand what it says. Can you tell me what this Datadog monitor message is saying: {{ Steps.Get_event_monitor_alert_details.event.text }}
      • 1つ前の step の event.text を利用していますね
    • Simplify language of alert
      • OpenAI Edit text Action
      • 1つ前のステップの output をインプットにし、simplify することを指示しています
    • Create incident
      • Service Now: Create incident
      • Service now というサービスで Incident の short description に 1つ前のステップで simplify したテキストを入れています

アラートを受けて、そのアラート内容を OpenAI で要約して、Service Now でインシデントを宣言するという Workflow になっています。便利そうですね。

実際に試してみる

テスト用のアラートを作ってみます。テスト用なので全く意味のない以下のようなアラートを発火させてみます。

Monitor を Trigger とする場合、特定のキーワードを monitor の message に含める必要があります。今回は @workflow-chaspy-testSimplify-Language-of-a-Monitor-Alert" このような文字をアラートの本文に入れています。

はい、このように Monitor を分析して、それをまとめてくれました。

Describe the alert message

This Datadog monitor message is saying that the metric \"kubernetes.cpu.usage.total\" over the environment \"production\" was greater than 10,000,000,000.0 at least once during the last 5 minutes. The monitor was last triggered on Sunday, December 3, 2023, at 10:55:18 UTC. \n\nThe message also provides some additional options:\n- Monitor Status: View the status of the monitor.\n- Edit Monitor: Edit the configuration of the monitor.\n- Related Logs: View logs related to the monitor with the filter \"env:production\" and a specific time range.

Simplify language of alert

This Datadog monitor detected that the metric \"kubernetes.cpu.usage.total\" in the \"production\" environment exceeded 10,000,000,000.0 at least once in the last 5 minutes. The monitor was last triggered on Sunday, December 3, 2023, at 10:55:18 UTC.\n\nYou have three options:\n- Monitor Status: Check the current status of the monitor.\n- Edit Monitor: Make changes to the monitor's configuration.\n- Related Logs: Access logs related to the monitor, filtered by \"env:production\" and a specific time range."

こっちは全然 Simplify できてないですね。

終わりに

Datadog OpenAI Integration, API Key を入れるだけで気軽に使うことができました。

Datadog Workflow は個人的にはかなり推しの機能で、いろんなことができる可能性があると思います。レシピをシェアし合えるといいですね。

Azure OpenAI でも使えると良いですが、Workflow Action はなさそうでした。http request で api を直接呼べば同様のことはできそうです。

AI を使ってインシデント調査も楽にしていきましょう。