Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Eventing 3rd-party integrations backend

License

Notifications You must be signed in to change notification settings

RedHatInsights/eventing-integrations

Repository files navigation

⚠️ This repository is now archived. The integrations have been moved to the notifications-backend repository. ⚠️

Eventing – 3rd-party Integrations

ConsoleDot events integrations with 3rd-party tools (such as Splunk) build together with Notifications.

Currently supported integrations:

  • Splunk
  • ServiceNow

Development

Prerequisites

Setup

Set HTTP Event Collector (HEC) on your (local) Splunk and copy the token. Ensure that the HEC has SSL disabled and that all tokens are enabled.

Container Image Build

$ cd splunk-quarkus
$ podman build -f Dockerfile.jvm -t quay.io/cloudservices/eventing-integrations-splunk ..

Running

Note: All integrations are connecting to Kafka defined within ACG_CONFIG listenting on platform.notifications.tocamel topic.

Switching between integrations is done through two application properties:

  • camel.main.javaRoutesIncludePattern -- selects Camel routes
    • always include **/MainRoutes*,**/ErrorHandlingRoutes*
    • and then append concrete integration selector (e.g. ,**/Splunk*)
  • integrations.component.name -- selects messages out of Kafka for this type
    • ingress route selects messages of Cloud Event type com.redhat.console.notification.toCamel.<integrations.component.name>

For specific property configuration per integration type see below.

Running Splunk Integration

Running within container:

podman run -it -e ACG_CONFIG=/cdapp/devel.json -v devel.json:/cdapp/devel.json quay.io/cloudservices/eventing-integrations-splunk

You might ommit the interative terminal options -it if you want to have it running in background (detached).

To run it locally with dev mode execute:

$ cd splunk-quarkus
$ ACG_CONFIG=./devel.json ../mvnw quarkus:dev -Dcamel.main.javaRoutesIncludePattern="**/MainRoutes*,**/ErrorHandlingRoutes*,**/Splunk*" -Dintegrations.component.name=splunk -Dquarkus.kafka.devservices.enabled=false

Running Service Now Integration

To run Service Now integration locally with dev mode execute:

$ cd splunk-quarkus
$ ACG_CONFIG=./devel.json ../mvnw quarkus:dev -Dcamel.main.javaRoutesIncludePattern="**/MainRoutes*,**/ErrorHandlingRoutes*,**/ServiceNow*" -Dintegrations.component.name=servicenow -Dquarkus.kafka.devservices.enabled=false

Trying it out

Generate a message on platform.notifications.tocamel Kafka topic.

Manually this can be achieved for example by producing a message using kafka-console-producer.sh tool from Kafka:

kafka-console-producer.sh --bootstrap-server localhost:9092 --topic platform.notifications.tocamel

Here are CloudEvent examples for testing:

Splunk event

{"specversion":"1.0","type":"com.redhat.console.notification.toCamel.splunk","source":"notifications","id":"9dc9a4b1-8868-4afc-a69d-e8723b20452c","time":"2022-02-02T14:09:55.532551Z","rh-account":"12345","data":"{\"notif-metadata\":{\"url\":\"http://localhost:8088\",\"X-Insight-Token\":\"TOKEN\",\"extras\":\"{}\"},\"account_id\":\"12345\",\"org_id\":\"67890\",\"application\":\"advisor\",\"bundle\":\"rhel\",\"context\":{},\"event_type\":\"new-recommendation\",\"timestamp\":\"2022-02-02T14:09:55.344612\",\"events\":[{\"some\":\"eventdata\"}]}"}

ServiceNow event

{"specversion":"1.0","type":"com.redhat.console.notification.toCamel.servicenow","source":"notifications","id":"9dc9a4b1-8868-4afc-a69d-e8723b20452c","time":"2022-02-02T14:09:55.532551Z","rh-account":"12345","data":"{\"notif-metadata\":{\"url\":\"http://localhost:8088\",\"X-Insight-Token\":\"TOKEN\",\"extras\":\"{}\"},\"account_id\":\"12345\",\"org_id\":\"67890\",\"application\":\"advisor\",\"bundle\":\"rhel\",\"context\":{},\"event_type\":\"new-recommendation\",\"timestamp\":\"2022-02-02T14:09:55.344612\",\"events\":[{\"some\":\"eventdata\"}]}"}

(don't forget to replace TOKEN with your token or password)

Within platform this can be achieved for example using the Drift service:

  • registering a system
  • creating a baseline out of the registered system
  • assigning the system to baseline
  • chaning a fact of the baseline (e.g. bios) or changing the system (updating a package)
  • running a system check-in from the system

Running unit tests

With local dev mode

$ cd splunk-quarkus
$ ACG_CONFIG=./devel.json ../mvnw quarkus:dev -Dquarkus.kafka.devservices.enabled=false

running tests are paused.

You can hit o to toggle test output and r key to resume testing and again r to re-run tests.

Alternatively you can run tests via

$ ACG_CONFIG=./devel.json ../mvnw quarkus:test -Dquarkus.kafka.devservices.enabled=false

and use r to re-run tests.

It is also possible to run tests one-time

$ ACG_CONFIG=./devel.json ../mvnw test -Dquarkus.kafka.devservices.enabled=false

Development Notes

Updating Java Dependencies

The best way how to update Java/Quarkus dependencies is to update Quarkus platform version. The platform version is mapped to a set of dependent packages of Camel provided by a BOM (Bill of Materials) package io.quarkus.platform:quarkus-camel-bom (available from quarkusio/quarkus-platform).

CAUTION: Quarkus platform version needs to be set up to 2.11, as later versions use camel-quarkus that breaks use of camel.main.javaRoutesIncludePattern for integration switching.

See also

Process

  1. Check version of quarkus.platform.version project property whether it matches the newest possible version as per quarkus-camel-bom.
    • Note: always use .Final versions.
  2. Increase the minor version of quarkus.platform.version project property by one.
  3. Read Quarkus Migration guide for the minor version.
  4. Compile code with mvnw clean compile (from the corresponding directory) and check for errors.
  5. Repeat to increase the minor version up to the highest possible.
  6. Test the app, e.g. by running mvnw quarkus:dev.