Skip to content

Commit

Permalink
add dynatrace use case
Browse files Browse the repository at this point in the history
  • Loading branch information
kubealex committed Aug 21, 2023
1 parent b5fac20 commit 9299c44
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 5 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@ The stack is composed by four containers:
- Quarkus-client container that will act as an event generator
- Ansible EDA container image, running the ansible bits

The *eda-ansible* directory, all rulebooks and playbooks are present.
The *eda-quarkus-tester* directory contains the source code for the quarkus client
The _eda-ansible_ directory, all rulebooks and playbooks are present.
The _eda-quarkus-tester_ directory contains the source code for the quarkus client

A pre-built **podman-compose.yml** is present in the repo to allow a quick setup of the kafka/alertmanager/quarkus stack.

## Dynatrace demo

The use cases contain a Dynatrace integration.
To configure the integrations, ensure you use your API URL and API Token configured with the following permissions in the [dynatrace rulebook](./eda-ansible/eda-rulebook-dynatrace.yml):

- Read/Write problems
- Read/Write configuration
- Access problem and event feed, metrics, and topology

## Usage

Start your stack by issuing:
Expand Down
12 changes: 12 additions & 0 deletions eda-ansible/eda-playbook-dynatrace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- name: Dynatrace | Listen and react to events
hosts: localhost
tasks:
- name: Dynatrace | Sample listener
ansible.builtin.debug:
msg:
- "Problem detected on Dynatrace - Details:"
- Impact level: {{ dynatrace_problem_impact_level }}
- Problem Id: {{ dynatrace_problem_id }}
- Problem Title: {{ dynatrace_problem_title }}
- Problem Root Cause: {{ dynatrace_problem_root_cause }}
- Problem Status: {{ dynatrace_problem_status }}"
20 changes: 20 additions & 0 deletions eda-ansible/eda-rulebook-dynatrace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- name: Dynatrace | Listen and react to events
hosts: all
sources:
- dynatrace.event_driven_ansible.dt_esa_api:
dt_api_host: "<YOUR_TENANT_API>"
dt_api_token: "<YOUR_TENANT_API_TOKEN>"
delay: 60
rules:
- name: Dynatrace | Sample listener
condition: event.problemTitle is defined or event.status is defined
actions:
- debug:
- run_playbook:
name: eda-playbook-dynatrace.yml
extra_vars:
dynatrace_problem_impact_level: "{{ event.impactLevel }}"
dynatrace_problem_id: "{{ event.problemId }}"
dynatrace_problem_root_cause: "{{ event.rootCauseEntity }}"
dynatrace_problem_status: "{{ event.status }}"
dynatrace_problem_title: "{{ event.title }}"
18 changes: 18 additions & 0 deletions eda-ansible/eda-rulebook-multiple-sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,25 @@
port: 5002
token: redhatinsightstoken

- dynatrace.event_driven_ansible.dt_esa_api:
dt_api_host: "<YOUR_TENANT_API>"
dt_api_token: "<YOUR_TENANT_API_TOKEN>"
delay: 60

rules:
- name: Dynatrace | Sample listener
condition: event.problemTitle is defined or event.status is defined
actions:
- debug:
- run_playbook:
name: eda-playbook-dynatrace.yml
extra_vars:
dynatrace_problem_impact_level: "{{ event.impactLevel }}"
dynatrace_problem_id: "{{ event.problemId }}"
dynatrace_problem_root_cause: "{{ event.rootCauseEntity }}"
dynatrace_problem_status: "{{ event.status }}"
dynatrace_problem_title: "{{ event.title }}"

- name: Run playbook to greet our Kafka peers
condition: event.body.name == "greeting"
actions:
Expand Down
9 changes: 6 additions & 3 deletions eda-utils/Containerfile-ansible
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM registry.access.redhat.com/ubi9-minimal
RUN microdnf install java-17 python3 gcc python3-devel -y && microdnf clean all && python -m ensurepip --upgrade && pip3 install ansible ansible-rulebook asyncio aiokafka aiohttp aiosignal asyncio_mqtt
USER root
RUN microdnf install java-17 python3.11 gcc python3.11-devel -y
RUN rm -rf /usr/bin/python3 && ln -s python3.11 /usr/bin/python3
RUN microdnf clean all && python3 -m ensurepip --upgrade && pip3 install ansible ansible-rulebook asyncio aiokafka aiohttp aiosignal asyncio_mqtt
ENV JAVA_HOME="/usr/lib/jvm/jre-17"
RUN mkdir /eda-ansible
RUN ansible-galaxy collection install ansible.eda kubealex.eda redhatinsights.eda
RUN ansible-galaxy collection install ansible.eda dynatrace.event_driven_ansible kubealex.eda kubealex.general redhatinsights.eda
WORKDIR /eda-ansible
CMD ansible-rulebook -i inventory.yml --rulebook eda-rulebook-multiple-sources.yml --verbose
CMD ansible-rulebook -i inventory.yml --rulebook eda-rulebook-multiple-sources.yml --verbose

0 comments on commit 9299c44

Please sign in to comment.