Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RHCLOUD-22813] Handle provided context.host_url in integration templates #3221

Merged
merged 7 commits into from
Jan 24, 2025

Conversation

jessicarod7
Copy link
Member

@jessicarod7 jessicarod7 commented Dec 19, 2024

Jira issue

https://issues.redhat.com/browse/RHCLOUD-22813

Description

Currently, URLs in PagerDuty and Camel notifications are constructed by the PagerDutyTransformer, or one of three Qute templates, respectively. Each one has a slightly different way of handling URLs, and the Camel templates are not the ones currently shown in this repo.

This PR creates a new class, InsightsUrlsBuilder, which provides consistent construction of the two URLs for all integrations:

  • data.inventory_url represents a link to the specific host, cluster, or inventory item in the Console that generated the message. If data.context.host_url is provided, it will be used here.
  • data.application_url links back to the application that generated the event.

The PR will also make it easy to modify the URL format in a followup issue.

Database migration

A new migration file (V1.110.0) has been added. It takes the current templates used in the Notifications database, and updates them to use the new URLs.

These changes are now part of #3229.

Testing

  • Updated connector-pagerduty tests to emulate the new URL builder on the engine side.
  • Updated CamelProcessorTest implementers to use the new URLs in their Qute templates
  • Added a new test for PagerDuty and Camel to verify that data.context.host_url will always be used if present

Example

Using the following trimmed output from BaseTransformer:

{
  "bundle": "rhel",
  "application": "advisor",
  "event_type": "new-recommendation",
  "timestamp": "2024-12-19T15:21:45.129372",
  // trimmed
  "context": {
    "inventory_id": "6eaaa39c-55f7-4f45-81a9-84c75b1475d6",
    "hostname": "my-computer-jrodri",
    "display_name": "my-computer-jrodri",
    "host_url": "https://console.redhat.com/insights/inventory/some-unique-host-url-path",
    "tags": []
  },
  "events": [
    {
      // one event, trimmed
    },
    {
      // another event, trimmed
    }
  ],
  "source": {
    "application": {"display_name": "Advisor"},
    "bundle": {"display_name": "Red Hat Enterprise Linux"}
  }
  "environment_url": "https://console.redhat.com"
}

And the new Microsoft Teams template:

{"text":"{#if data.context.display_name??}[{data.context.display_name}]({data.inventory_url}) triggered {data.events.size()} event{#if data.events.size() \u003e 1}s{/if}{#else}{data.events.size()} event{#if data.events.size() \u003e 1}s{/if} triggered{/if} from {data.source.application.display_name} - {data.source.bundle.display_name}. [Open {data.source.application.display_name}]({data.application_url})"}

We generate this message:

[my-computer-jrodri](https://console.redhat.com/insights/inventory/some-unique-host-url-path) triggered 2 events from Advisor - Red Hat Enterprise Linux. [Open Advisor](https://console.redhat.com/insights/advisor)

Copy link
Contributor

@g-duval g-duval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work Jessica :)
Because tis PR will involve some braking changes, I think it should be split in two PRs for camel processor case, like:

  1. Introduce new entries into data source object
  2. Update Qute templates and remove deprecated data from data source object (like environnment_url)

WDYT?

@jessicarod7
Copy link
Member Author

Agree with splitting the PRs. I'll open a new one later today.

@jessicarod7 jessicarod7 force-pushed the RHCLOUD-22813 branch 2 times, most recently from 844fc7d to 7c24129 Compare January 7, 2025 23:36
@g-duval
Copy link
Contributor

g-duval commented Jan 13, 2025

/retest

@g-duval
Copy link
Contributor

g-duval commented Jan 13, 2025

@jessicarod7 it looks like those changes breaks test_integration_pagerduty_event_triggered IQE test.
Could you please have a look and confirm if it was expected while waiting for a test case update?

@jessicarod7
Copy link
Member Author

wasn't expecting this one to fail, looking into it

@jessicarod7
Copy link
Member Author

@g-duval since I can no longer view the Jenkins build (and my attempts to deploy to ephemeral keep timing out), I'm unable to identify why that IQE test is failing

@MikelAlejoBR
Copy link
Member

/retest

@g-duval
Copy link
Contributor

g-duval commented Jan 20, 2025

@jessicarod7 , that's right, iqe test execution and logs were moved into Konflux last week, you can check them here.

@jessicarod7
Copy link
Member Author

IQE issue fixed, I misformatted the .links section, which violated PD-CEF and caused PagerDuty to drop the alerts.

@g-duval
Copy link
Contributor

g-duval commented Jan 24, 2025

Awesome, thank you

Copy link
Contributor

@g-duval g-duval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@g-duval g-duval merged commit 3cb75a0 into RedHatInsights:master Jan 24, 2025
47 checks passed
@jessicarod7 jessicarod7 deleted the RHCLOUD-22813 branch January 24, 2025 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants