Repository navigation
feat(monitoring): add DigitalOcean monitoring alert policy and droplet metrics tasks - #27
Conversation
|
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. |
fdelbrayelle
left a comment
There was a problem hiding this comment.
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.mdand thedescriptioninsrc/main/resources/metadata/index.yamldo not mention the newmonitoringsubpackages (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
|
Hi @fdelbrayelle, @MilosPaunovic, I have addressed all 6 review points:
Please take another look when you get a chance. |
fdelbrayelle
left a comment
There was a problem hiding this comment.
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.javadisk_read/disk_write:DiskMetricTypenow maps todisk_read/disk_writeandDropletDiskTesthas one test per type. - ✅
SlackAlert.javawebhook URL in outputs (KPS-01):SlackAlert.fromno longer copiesurl, andalertpolicy.List.transformRowsstrips it. - ✅
Create.javaclosed values as strings:PolicyType,Compare,Window,NetworkInterface,TrafficDirection,DiskMetricType,MemoryMetricTypeenums added. - ✅
Update.javaduplication with Create: sharedAbstractAlertPolicyTaskwithbuildPayload. - ✅
DropletCpu.javastring epoch seconds:Property<Instant>in the newAbstractDropletMetricsTask, shared by the four tasks. - ✅ Docs not updated:
README.md,AGENTS.md,io.kestra.plugin.digitalocean.mdandmetadata/index.yamlnow mentionmonitoring.
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) { |
There was a problem hiding this comment.
🟡 [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; |
There was a problem hiding this comment.
🟡 [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).
QA report (head
|
| 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)"| 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 }}"| 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.Excludeonalerts: 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.
|
@fdelbrayelle, addressed both points:
|
Summary of Changes
Adds support for the DigitalOcean Monitoring API:
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.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.Models & Verification:
AlertChannels,SlackAlert,MetricSeries,MetricDataPoint.package-info.java, metadata YAMLs and SVG icons (passedlintPluginDocs).Closes #26
Part of #10