Skip to content

feat(monitoring): add DigitalOcean monitoring alert policy and droplet metrics tasks - #27

Merged
fdelbrayelle merged 5 commits into
kestra-io:mainfrom
Binayak490-cyber:feat-issue-10-monitoring
Oct 13, 2026
Merged

fdelbrayelle merged 5 commits into
kestra-io:mainfrom
Binayak490-cyber:feat-issue-10-monitoring

Conversation

@Binayak490-cyber

Copy link
Copy Markdown
Contributor

Summary of Changes

Adds support for the DigitalOcean Monitoring API:

  1. Alert Policy Tasks (io.kestra.plugin.digitalocean.monitoring.alertpolicy):

    • Create: Create an alert policy.
    • Get: Retrieve an alert policy by UUID.
    • Update: Update an alert policy by UUID.
    • Delete: Delete an alert policy by UUID.
    • List: List alert policies with automatic pagination support.
  2. Droplet Metrics Tasks (io.kestra.plugin.digitalocean.monitoring.metrics):

    • DropletCpu: Fetch Droplet CPU utilization metrics.
    • DropletMemory: Fetch Droplet memory metrics (free, available, cached, total).
    • DropletBandwidth: Fetch Droplet inbound/outbound bandwidth metrics (public & private).
    • DropletDisk: Fetch Droplet filesystem metrics.
  3. Models & Verification:

    • Added models AlertChannels, SlackAlert, MetricSeries, MetricDataPoint.
    • Comprehensive WireMock unit tests covering all tasks, pagination and error scenarios.
    • Added package-info.java, metadata YAMLs and SVG icons (passed lintPluginDocs).

Closes #26
Part of #10

@kestrabot kestrabot Bot added this to Pull Requests Oct 9, 2026
@Binayak490-cyber

Copy link
Copy Markdown
Contributor Author

Hi @fdelbrayelle, @Coding-with-Adam, @jymaire, the PR for the Monitoring slice is ready for review. It includes full CRUD for Alert Policies, Droplet Metrics tasks, WireMock unit tests and plugin docs/metadata.

Can you please take a look at it.

@MilosPaunovic MilosPaunovic added the area/plugin Plugin-related issue or feature request label Oct 12, 2026
@MilosPaunovic
MilosPaunovic requested review from a team and fdelbrayelle October 12, 2026 07:43
@MilosPaunovic MilosPaunovic added the kind/external Pull requests raised by community contributors label Oct 12, 2026

@fdelbrayelle fdelbrayelle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Kestra Plugin Code Review

Business Requirements — met

Issue #26 asks for alertpolicy List/Get/Create/Update/Delete and metrics DropletBandwidth/Cpu/Memory/Disk; all nine tasks are present. Note: the linked issue still carries the kestra-bot:not-ready notice, so a maintainer should confirm the work was cleared to start.

Kestra Guidelines — 5 findings

  • 🟠 metrics/DropletDisk.java:61 [Guidelines] Disk metric types read and write hit a non-existent endpoint
  • 🟡 alertpolicy/Create.java:79 [Guidelines] Closed-value properties declared as free strings
  • 🟡 alertpolicy/Update.java:111 [Guidelines] Create and Update duplicate all properties and payload building
  • 🟡 metrics/DropletCpu.java:62 [Guidelines] start and end are string epoch seconds
  • 🟠 (no anchorable line) Docs not updated: src/main/resources/doc/io.kestra.plugin.digitalocean.md, AGENTS.md, README.md and the description in src/main/resources/metadata/index.yaml do not mention the new monitoring subpackages (alertpolicy, metrics), as required for new subpackages and plugin how-to docs.

Security (OWASP Top 10:2025 + KPS) — 1 finding

  • 🟠 models/SlackAlert.java:17 [Security] Slack webhook URL is returned in task outputs (KPS-01)

Performance — 0 findings

✅ No issues found

CI: check / main passed on 975155e. No build, wrapper or .github changes in this PR.

Verdict: REQUEST CHANGES

@Binayak490-cyber

Copy link
Copy Markdown
Contributor Author

Hi @fdelbrayelle, @MilosPaunovic,

I have addressed all 6 review points:

  • Masked Slack webhook URLs in outputs & sanitized list rows
  • Fixed DropletDisk endpoints (disk_read/disk_write) and added tests for all 4 types
  • Replaced closed strings with typed enums
  • Extracted AbstractAlertPolicyTask & AbstractDropletMetricsTask
  • Switched metrics time bounds to Property<Instant>
  • Updated plugin docs, README, and metadata (all lint checks passing)

Please take another look when you get a chance.

@fdelbrayelle fdelbrayelle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Kestra Plugin Code Review

Business Requirements — met

Issue #26 scope (alertpolicy CRUD/List, four Droplet metrics tasks) is still fully covered; the follow-up commit only reworks properties, docs and outputs.

Previous Review Follow-up — 6 of 6 addressed

Baseline: 975155e. New code reviewed: b20dd44 and the merge ea1fcf5.

  • ✅ DropletDisk.java disk_read/disk_write: DiskMetricType now maps to disk_read/disk_write and DropletDiskTest has one test per type.
  • ✅ SlackAlert.java webhook URL in outputs (KPS-01): SlackAlert.from no longer copies url, and alertpolicy.List.transformRows strips it.
  • ✅ Create.java closed values as strings: PolicyType, Compare, Window, NetworkInterface, TrafficDirection, DiskMetricType, MemoryMetricType enums added.
  • ✅ Update.java duplication with Create: shared AbstractAlertPolicyTask with buildPayload.
  • ✅ DropletCpu.java string epoch seconds: Property<Instant> in the new AbstractDropletMetricsTask, shared by the four tasks.
  • ✅ Docs not updated: README.md, AGENTS.md, io.kestra.plugin.digitalocean.md and metadata/index.yaml now mention monitoring.
    Threads resolved: 5 (all my earlier inline threads, each verified on the current head).

Kestra Guidelines — 1 finding

  • 🟡 alertpolicy/List.java:67 [Tests] Slack URL stripping has no test

Security (OWASP Top 10:2025 + KPS) — 1 finding

  • 🟡 alertpolicy/AbstractAlertPolicyTask.java:67 [Security] Webhook URL printed by generated toString (KPS-07)

Performance — 0 findings

✅ No issues found

No build, wrapper or .github changes in the PR files (the gradle.properties version bump in the compare range comes from the merge of main). The Main workflow run on the fork head was in action_required and has been approved. Not built locally.

Verdict: APPROVE


@Override
@SuppressWarnings("unchecked")
protected java.util.List<Map<String, Object>> transformRows(RunContext runContext, java.util.List<Map<String, Object>> rows) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🟡 [Tests] Slack URL stripping has no test
Problem: transformRows is the only guard keeping webhook URLs out of List outputs, but ListTest was not changed and does not assert that alerts.slack[].url is absent, so a regression would pass CI.
Fix: Add a ListTest case with a stubbed policy containing a Slack url and assert the returned rows carry only channel.

@Schema(title = "Notification channels")
@NotNull
@PluginProperty(group = "main")
protected Property<AlertChannels> alerts;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🟡 [Security] Webhook URL printed by generated toString (KPS-07)
Problem: alerts holds SlackAlert.url (a credential) and the class uses Lombok @ToString, so any log or dump of the task prints the webhook URL when the value is set inline.
Fix: Add @ToString.Exclude to alerts (and @ToString.Exclude on SlackAlert.url).

@fdelbrayelle

Copy link
Copy Markdown
Member

QA report (head ea1fcf5)

Edition: OSS | Docker tag: v1.3.42 (plugin kestraVersion 1.3.39 line), then v2.0.5 with the same JAR
Instance: http://localhost:18227 (left running, currently v2.0.5; docker rm -f qa-do27-kestra qa-do27-mock to stop)
Screenshots: https://claude.ai/artifact/Rb5d1yBNjsrVUgiBjv2GAR
API: DigitalOcean mocked locally (64 MB Python container, canned alert-policy JSON incl. fake Slack webhook URLs) and reached through the tasks' baseUrl property. No real account or credential used.

Result: PASS for the scenarios below. Metrics tasks (Droplet CPU, Memory, Disk, Bandwidth) were not exercised: they were out of the requested scope (alert policies).

PR JAR verified as the one loaded on both images (on 2.0.5 the bundled plugin-digitalocean 1.0.4 was removed from the QA container, and the alertpolicy task docs resolve only with the PR JAR).

Flow v1.3.42 v2.0.5
do27_list SUCCESS SUCCESS
do27_crud (Create, Get, Update, Delete) SUCCESS SUCCESS
do27_notfound (Get unknown uuid) FAILED as expected FAILED as expected

Flow 1: do27_list (SUCCESS)

Flow YAML
id: do27_list
namespace: qa.do27
tasks:
  - id: list_policies
    type: io.kestra.plugin.digitalocean.monitoring.alertpolicy.List
    apiToken: "fake-token-for-mock"
    baseUrl: "http://mock:8080"
    fetchType: FETCH
  - id: log_count
    type: io.kestra.plugin.core.log.Log
    message: "Found {{ outputs.list_policies.total }} alert policy(ies)"

Gantt (1.3.42, 2.0.5)

Task Status Duration
list_policies SUCCESS 0.7s (1.3.42) / 0.3s (2.0.5)
log_count SUCCESS <0.1s
Total SUCCESS

Logs synthesis: "Listing DigitalOcean alert policy(ies)", one GET /v2/monitoring/alerts?per_page=200 returned 200, "Found 3 alert policy(ies)". No webhook URL in any log line.

Outputs synthesis (screenshot): rows (3 items), size: 3, total: 3. The mock returns a slack.url for every policy; in every row the output is slack: [{channel: "#alerts"}], so the webhook URL is stripped from List outputs on both images.

Flow 2: do27_crud (SUCCESS)

Flow YAML
id: do27_crud
namespace: qa.do27
tasks:
  - id: create_alert
    type: io.kestra.plugin.digitalocean.monitoring.alertpolicy.Create
    apiToken: "fake-token-for-mock"
    baseUrl: "http://mock:8080"
    policyType: CPU
    policyDescription: "High CPU usage on production droplets"
    compare: GREATER_THAN
    value: 85.0
    window: FIVE_MINUTES
    entities: ["12345678"]
    alerts:
      email: ["ops@company.com"]
      slack:
        - url: "https://hooks.slack.com/services/TFAKE/BFAKE/CREATEFAKE"
          channel: "#alerts"
  - id: get_alert
    type: io.kestra.plugin.digitalocean.monitoring.alertpolicy.Get
    apiToken: "fake-token-for-mock"
    baseUrl: "http://mock:8080"
    alertUuid: "{{ outputs.create_alert.uuid }}"
  - id: update_alert
    type: io.kestra.plugin.digitalocean.monitoring.alertpolicy.Update
    apiToken: "fake-token-for-mock"
    baseUrl: "http://mock:8080"
    alertUuid: "{{ outputs.create_alert.uuid }}"
    policyType: CPU
    policyDescription: "Updated description"
    compare: GREATER_THAN
    value: 90.0
    window: TEN_MINUTES
    entities: ["12345678"]
    alerts:
      email: ["ops@company.com"]
  - id: delete_alert
    type: io.kestra.plugin.digitalocean.monitoring.alertpolicy.Delete
    apiToken: "fake-token-for-mock"
    baseUrl: "http://mock:8080"
    alertUuid: "{{ outputs.create_alert.uuid }}"

Gantt (1.3.42, 2.0.5)

Task Status Duration
create_alert SUCCESS 0.05 to 0.7s
get_alert SUCCESS <0.1s
update_alert SUCCESS <0.1s
delete_alert SUCCESS <0.1s
Total SUCCESS

Logs synthesis: one INFO line per task (create, fetch, update, delete), mock saw POST, GET, PUT, DELETE (204) with the auth header present. The literal webhook URL never appears in logs.

Outputs synthesis (1.3.42, 2.0.5): Create and Get return uuid, type, description, compare: greater_than, value: 85.0, window: 5m, entities, tags, enabled, and alerts.slack: [{channel: "#alerts"}] (URL not exposed in outputs). Update returns the new description, value 90.0, window 10m. Delete has no output.

Flow 3: do27_notfound (FAILED, expected)

id: do27_notfound
namespace: qa.do27
tasks:
  - id: get_missing
    type: io.kestra.plugin.digitalocean.monitoring.alertpolicy.Get
    apiToken: "fake-token-for-mock"
    baseUrl: "http://mock:8080"
    alertUuid: "does-not-exist"

Gantt (1.3.42, 2.0.5): get_missing FAILED in about 0.05 to 0.7s.
Logs (screenshot): ERROR "DigitalOcean API returned HTTP 404: resource not found. Verify baseUrl ... The resource you requested could not be found." Clear message, no token in it.

Review points

  • Slack webhook stripping on List outputs: verified working (also not exposed in Create, Get, Update outputs).
  • Missing @ToString.Exclude on alerts: not observable from the UI. No webhook URL appeared in any log, output or error on either image, so no runtime leak was reproduced. The concern stays a static one.

Not covered

  • List pagination across several pages (mock returned 3 items in one page).
  • Droplet metrics tasks (out of scope here).
  • Behaviour against the real DigitalOcean API: NOT TESTABLE without a real account (payload shape and enum mapping were checked only against the mock).
  • No steering text found in the PR content.

@Binayak490-cyber

Binayak490-cyber commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

@fdelbrayelle, addressed both points:

  1. Added @ToString.Exclude on alerts in AbstractAlertPolicyTask and on SlackAlert.url so webhook URLs are never printed in generated toString().
  2. Updated ListTest to explicitly assert that alerts.slack[].url is stripped from outputs and only channel is returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/plugin Plugin-related issue or feature request kind/external Pull requests raised by community contributors

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

DigitalOcean: add Monitoring tasks (part of #10)

3 participants