OpenSearch ISM Policy Compliance Gate
Check an index's ISM policy attachment through the ISM Explain API, alert Slack on a gap or an unreachable index, and optionally attach the expected policy with the ISM Add Policy API.
Build a 15-minute Energy-Charts mart for two markets and fail when derived renewable share or residual load disagrees.
id: energy-charts-renewable-share-price-mart
namespace: company.markets
description: |
Load 15-minute electricity generation and day-ahead prices for two European markets from the public Fraunhofer ISE Energy-Charts API, rebuild renewable share and residual load in DuckDB, and fail when those figures disagree with the published series. The API needs no key. A schedule runs each morning; manual Execute uses the same tasks.
inputs:
- id: country_1
type: STRING
defaults: de
displayName: First country
description: Energy-Charts country code. `de` is Germany. Lowercase, two letters.
- id: zone_1
type: STRING
defaults: DE-LU
displayName: First bidding zone
description: Day-ahead price zone for country 1. `DE-LU` is the
German-Luxembourg zone used by SMARD.
- id: country_2
type: STRING
defaults: fr
displayName: Second country
description: Second Energy-Charts country code. `fr` is France. Must differ from
country 1.
- id: zone_2
type: STRING
defaults: FR
displayName: Second bidding zone
description: Day-ahead price zone for country 2.
- id: start_date
type: STRING
defaults: auto
displayName: First local day
description: "`auto`, or `YYYY-MM-DD` in Europe/Berlin. `auto` is four days
before the run."
- id: end_date
type: STRING
defaults: auto
displayName: Last local day
description: "`auto`, or `YYYY-MM-DD` in Europe/Berlin. `auto` is two days
before the run, so the window is already published. `end_date` is
inclusive."
- id: waste_renewable_fraction
type: FLOAT
defaults: 0.5
min: 0
max: 1
displayName: Biogenic share of waste
description: Fraction of the Waste series counted as renewable. Energy-Charts
uses one half for Germany and France. The other half stays in the
generation total.
- id: share_tolerance_pp
type: FLOAT
defaults: 0.2
min: 0
max: 5
displayName: Share tolerance (percentage points)
description: Largest absolute gap allowed between each derived renewable share
and the published share. Applies to share of generation and share of load.
- id: residual_tolerance_mw
type: FLOAT
defaults: 1
min: 0
max: 50
displayName: Residual-load tolerance (MW)
description: Largest absolute gap allowed between derived residual load and the
published residual load. Derived residual load is load minus onshore wind,
offshore wind, and solar.
- id: max_missing_intervals
type: INT
defaults: 0
min: 0
displayName: Missing-interval budget
description: Largest number of quarter-hours, across both markets, that may be
null, misaligned, or deprecated. The default rejects any gap.
triggers:
- id: morning_market_refresh
type: io.kestra.plugin.core.trigger.Schedule
cron: "10 7 * * *"
timezone: Europe/Berlin
recoverMissedSchedules: NONE
description: |
07:10 Europe/Berlin, after the previous days are on the Energy-Charts API. Missed runs are not replayed, so importing the flow does not backfill.
concurrency:
limit: 1
behavior: QUEUE
tasks:
- id: inputs_ok
type: io.kestra.plugin.core.flow.If
description: Refuse codes that could change the request URL or the SQL before
any call is sent.
condition: "{{ (inputs.country_1 | regexMatch(regex='^[a-z]{2}$')) and
(inputs.country_2 | regexMatch(regex='^[a-z]{2}$')) and inputs.country_1
!= inputs.country_2 and (inputs.zone_1 |
regexMatch(regex='^[A-Z][A-Z0-9-]{1,15}$')) and (inputs.zone_2 |
regexMatch(regex='^[A-Z][A-Z0-9-]{1,15}$')) and (inputs.start_date |
regexMatch(regex='^(auto|[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]\
))$')) and (inputs.end_date |
regexMatch(regex='^(auto|[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]\
))$')) and (inputs.start_date == 'auto' or inputs.end_date == 'auto' or
inputs.start_date <= inputs.end_date) and inputs.waste_renewable_fraction
>= 0 and inputs.waste_renewable_fraction <= 1 and
inputs.share_tolerance_pp >= 0 and inputs.share_tolerance_pp <= 5 and
inputs.residual_tolerance_mw >= 0 and inputs.residual_tolerance_mw <= 50
and inputs.max_missing_intervals >= 0 }}"
then:
- id: resolve_window
type: io.kestra.plugin.core.output.OutputValues
description: Freeze the Europe/Berlin dates once, so the downloads and the
coverage check use the same window.
values:
start_date: "{{ inputs.start_date == 'auto' ? (now() | dateAdd(-4, 'DAYS') |
date('yyyy-MM-dd', timeZone='Europe/Berlin')) : inputs.start_date
}}"
end_date: "{{ inputs.end_date == 'auto' ? (now() | dateAdd(-2, 'DAYS') |
date('yyyy-MM-dd', timeZone='Europe/Berlin')) : inputs.end_date }}"
- id: previous_window
type: io.kestra.plugin.core.kv.Get
description: Last window accepted for this pair of markets. Absent on the first
pass.
key: "energy_charts_share_price_{{ inputs.country_1 }}_{{ inputs.country_2 }}_{{
inputs.zone_1 }}_{{ inputs.zone_2 }}"
errorOnMissing: false
- id: fetch_markets
type: io.kestra.plugin.core.flow.Parallel
description: Generation and day-ahead price are different calls. Fetch both
markets together.
tasks:
- id: fetch_power_1
type: io.kestra.plugin.core.http.Download
description: 15-minute public generation for country 1, in MW. No API key.
uri: "https://api.energy-charts.info/public_power?country={{ inputs.country_1
}}&start={{ outputs.resolve_window.values.start_date }}&end={{
outputs.resolve_window.values.end_date }}"
headers:
Accept: application/json
User-Agent: kestra-energy-charts-renewable-share-price-mart/1.0
(+https://kestra.io)
options:
timeout:
readIdleTimeout: PT1M
retry:
type: exponential
interval: PT10S
maxInterval: PT1M
maxAttempts: 4
- id: fetch_price_1
type: io.kestra.plugin.core.http.Download
description: 15-minute day-ahead price for zone 1, in EUR/MWh.
uri: "https://api.energy-charts.info/price?bzn={{ inputs.zone_1 }}&start={{
outputs.resolve_window.values.start_date }}&end={{
outputs.resolve_window.values.end_date }}"
headers:
Accept: application/json
User-Agent: kestra-energy-charts-renewable-share-price-mart/1.0
(+https://kestra.io)
options:
timeout:
readIdleTimeout: PT1M
retry:
type: exponential
interval: PT10S
maxInterval: PT1M
maxAttempts: 4
- id: fetch_power_2
type: io.kestra.plugin.core.http.Download
description: 15-minute public generation for country 2, in MW.
uri: "https://api.energy-charts.info/public_power?country={{ inputs.country_2
}}&start={{ outputs.resolve_window.values.start_date }}&end={{
outputs.resolve_window.values.end_date }}"
headers:
Accept: application/json
User-Agent: kestra-energy-charts-renewable-share-price-mart/1.0
(+https://kestra.io)
options:
timeout:
readIdleTimeout: PT1M
retry:
type: exponential
interval: PT10S
maxInterval: PT1M
maxAttempts: 4
- id: fetch_price_2
type: io.kestra.plugin.core.http.Download
description: 15-minute day-ahead price for zone 2, in EUR/MWh.
uri: "https://api.energy-charts.info/price?bzn={{ inputs.zone_2 }}&start={{
outputs.resolve_window.values.start_date }}&end={{
outputs.resolve_window.values.end_date }}"
headers:
Accept: application/json
User-Agent: kestra-energy-charts-renewable-share-price-mart/1.0
(+https://kestra.io)
options:
timeout:
readIdleTimeout: PT1M
retry:
type: exponential
interval: PT10S
maxInterval: PT1M
maxAttempts: 4
- id: build_mart
type: io.kestra.plugin.jdbc.duckdb.Queries
description: |
Align generation with price on the 15-minute timestamp, then rebuild the two published renewable shares and residual load.
Renewable power is hydro run-of-river, hydro reservoir, biomass, geothermal, solar, and both wind series, plus the biogenic fraction of waste.
The generation total adds the rest of waste and every other production type (nuclear, fossil, Others). Pumped storage, batteries, consumption, and cross-border trade stay out of both sides.
Residual load is load minus onshore wind, offshore wind, and solar. A wind-offshore series that the country does not publish counts as zero; a null inside a published series is a gap.
Quarter-hours are 0.25 h, so energy in the daily file is MW times 0.25. The clock is Europe/Berlin, which is the calendar the API uses. UTC steps stay 900 seconds across the autumn and spring clock changes.
url: "jdbc:duckdb:"
fetchType: FETCH_ONE
inputFiles:
power_1.json: "{{ outputs.fetch_power_1.uri }}"
price_1.json: "{{ outputs.fetch_price_1.uri }}"
power_2.json: "{{ outputs.fetch_power_2.uri }}"
price_2.json: "{{ outputs.fetch_price_2.uri }}"
outputFiles:
- intervals
- daily_summary
sql: |
CREATE TABLE files AS
SELECT '{{ inputs.country_1 }}' AS country, '{{ inputs.zone_1 }}' AS bidding_zone, 'power' AS kind, content FROM read_text('power_1.json')
UNION ALL
SELECT '{{ inputs.country_1 }}', '{{ inputs.zone_1 }}', 'price', content FROM read_text('price_1.json')
UNION ALL
SELECT '{{ inputs.country_2 }}', '{{ inputs.zone_2 }}', 'power', content FROM read_text('power_2.json')
UNION ALL
SELECT '{{ inputs.country_2 }}', '{{ inputs.zone_2 }}', 'price', content FROM read_text('price_2.json');
CREATE TABLE power_points AS
SELECT f.country, f.bidding_zone, CAST(j.key AS INTEGER) AS idx,
TRY_CAST(j.value AS BIGINT) AS unix_seconds,
TRY_CAST(json_extract(f.content, '$.deprecated') AS BOOLEAN) AS deprecated
FROM files f, json_each(json_extract(f.content, '$.unix_seconds')) j
WHERE f.kind = 'power';
CREATE TABLE power_series AS
SELECT f.country, f.bidding_zone,
json_extract_string(pt.value, '$.name') AS name,
CAST(d.key AS INTEGER) AS idx,
TRY_CAST(d.value AS DOUBLE) AS mw
FROM files f,
json_each(json_extract(f.content, '$.production_types')) pt,
json_each(json_extract(pt.value, '$.data')) d
WHERE f.kind = 'power';
CREATE TABLE price_points AS
SELECT f.country, f.bidding_zone, CAST(j.key AS INTEGER) AS idx,
TRY_CAST(j.value AS BIGINT) AS unix_seconds,
TRY_CAST(json_extract(f.content, '$.deprecated') AS BOOLEAN) AS deprecated,
json_extract_string(f.content, '$.unit') AS unit
FROM files f, json_each(json_extract(f.content, '$.unix_seconds')) j
WHERE f.kind = 'price';
CREATE TABLE price_values AS
SELECT f.country, f.bidding_zone, CAST(j.key AS INTEGER) AS idx,
TRY_CAST(j.value AS DOUBLE) AS price_eur_mwh
FROM files f, json_each(json_extract(f.content, '$.price')) j
WHERE f.kind = 'price';
CREATE TABLE typed AS
SELECT country, bidding_zone, idx, name, mw,
CASE
WHEN name IN ('Load', 'Residual load', 'Renewable share of load', 'Renewable share of generation') THEN 'metric'
WHEN name IN ('Cross border electricity trading', 'Hydro pumped storage consumption', 'Battery Consumption') THEN 'skip'
WHEN name IN ('Hydro pumped storage', 'Battery') THEN 'storage'
WHEN name IN ('Hydro Run-of-River', 'Hydro water reservoir', 'Biomass', 'Geothermal', 'Solar', 'Wind offshore', 'Wind onshore') THEN 'renewable'
WHEN name = 'Waste' THEN 'waste'
ELSE 'other'
END AS role
FROM power_series;
CREATE TABLE intervals AS
WITH agg AS (
SELECT country, bidding_zone, idx,
max(CASE WHEN name = 'Load' THEN mw END) AS load_mw,
max(CASE WHEN name = 'Residual load' THEN mw END) AS residual_published_mw,
max(CASE WHEN name = 'Renewable share of generation' THEN mw END) AS share_generation_published_pct,
max(CASE WHEN name = 'Renewable share of load' THEN mw END) AS share_load_published_pct,
max(CASE WHEN name = 'Solar' THEN mw END) AS solar_mw,
max(CASE WHEN name = 'Wind onshore' THEN mw END) AS wind_onshore_mw,
max(CASE WHEN name = 'Wind offshore' THEN mw END) AS wind_offshore_raw,
max(CASE WHEN name = 'Wind offshore' THEN 1 ELSE 0 END) AS offshore_present,
max(CASE WHEN name = 'Waste' THEN mw END) AS waste_raw,
max(CASE WHEN name = 'Waste' THEN 1 ELSE 0 END) AS waste_present,
sum(mw) FILTER (WHERE role = 'renewable') AS renewable_sum,
count(*) FILTER (WHERE role = 'renewable' AND mw IS NULL) AS renewable_nulls,
sum(mw) FILTER (WHERE role = 'other') AS other_sum,
count(*) FILTER (WHERE role = 'other' AND mw IS NULL) AS other_nulls,
count(*) FILTER (WHERE role = 'waste' AND mw IS NULL) AS waste_nulls,
count(*) FILTER (WHERE name = 'Load' AND mw IS NOT NULL) AS has_load,
count(*) FILTER (WHERE name = 'Residual load' AND mw IS NOT NULL) AS has_residual,
count(*) FILTER (WHERE name = 'Renewable share of generation' AND mw IS NOT NULL) AS has_share_gen,
count(*) FILTER (WHERE name = 'Renewable share of load' AND mw IS NOT NULL) AS has_share_load,
count(*) FILTER (WHERE name = 'Solar' AND mw IS NOT NULL) AS has_solar,
count(*) FILTER (WHERE name = 'Wind onshore' AND mw IS NOT NULL) AS has_wind_on
FROM typed
GROUP BY country, bidding_zone, idx
),
joined AS (
SELECT p.country, p.bidding_zone, p.idx, p.unix_seconds, p.deprecated AS power_deprecated,
a.load_mw, a.residual_published_mw, a.share_generation_published_pct, a.share_load_published_pct,
a.solar_mw, a.wind_onshore_mw, a.wind_offshore_raw, a.offshore_present, a.waste_raw, a.waste_present,
a.renewable_sum, a.other_sum, a.renewable_nulls, a.other_nulls, a.waste_nulls,
a.has_load, a.has_residual, a.has_share_gen, a.has_share_load, a.has_solar, a.has_wind_on,
pv.price_eur_mwh, pp.unit AS price_unit, pp.deprecated AS price_deprecated, pp.unix_seconds AS price_unix
FROM power_points p
LEFT JOIN agg a USING (country, bidding_zone, idx)
LEFT JOIN price_values pv USING (country, bidding_zone, idx)
LEFT JOIN price_points pp USING (country, bidding_zone, idx)
)
SELECT
country,
bidding_zone,
unix_seconds,
to_timestamp(unix_seconds) AS ts_utc,
timezone('Europe/Berlin', to_timestamp(unix_seconds)) AS ts_local,
CAST(timezone('Europe/Berlin', to_timestamp(unix_seconds)) AS DATE) AS local_date,
load_mw,
solar_mw,
wind_onshore_mw,
CASE WHEN offshore_present = 1 THEN wind_offshore_raw ELSE 0 END AS wind_offshore_mw,
CASE WHEN waste_present = 1 THEN waste_raw ELSE 0 END AS waste_mw,
CASE
WHEN renewable_nulls > 0 OR renewable_sum IS NULL THEN NULL
ELSE renewable_sum + {{ inputs.waste_renewable_fraction }} * (CASE WHEN waste_present = 1 THEN waste_raw ELSE 0 END)
END AS renewable_mw,
CASE
WHEN renewable_nulls > 0 OR other_nulls > 0 OR waste_nulls > 0 OR renewable_sum IS NULL THEN NULL
ELSE renewable_sum + (CASE WHEN waste_present = 1 THEN waste_raw ELSE 0 END) + coalesce(other_sum, 0)
END AS generation_mw,
residual_published_mw,
share_generation_published_pct,
share_load_published_pct,
price_eur_mwh,
price_unit,
CASE
WHEN unix_seconds IS NULL THEN 'missing timestamp'
WHEN power_deprecated IS TRUE OR price_deprecated IS TRUE THEN 'deprecated payload'
WHEN price_unix IS DISTINCT FROM unix_seconds OR price_eur_mwh IS NULL THEN 'price misaligned'
WHEN coalesce(has_load, 0) = 0 OR coalesce(has_residual, 0) = 0 OR coalesce(has_share_gen, 0) = 0
OR coalesce(has_share_load, 0) = 0 OR coalesce(has_solar, 0) = 0 OR coalesce(has_wind_on, 0) = 0 THEN 'required series missing'
WHEN renewable_nulls > 0 OR other_nulls > 0 OR waste_nulls > 0 THEN 'null generation'
WHEN offshore_present = 1 AND wind_offshore_raw IS NULL THEN 'null wind offshore'
WHEN load_mw = 0 OR renewable_sum IS NULL THEN 'empty generation'
WHEN price_unit IS NULL OR price_unit NOT ILIKE '%EUR%' THEN 'unexpected price unit'
ELSE NULL
END AS gap_reason
FROM joined;
CREATE TABLE mart AS
SELECT
country,
bidding_zone,
unix_seconds,
ts_utc,
ts_local,
local_date,
load_mw,
solar_mw,
wind_onshore_mw,
wind_offshore_mw,
waste_mw,
renewable_mw,
generation_mw,
load_mw - wind_onshore_mw - wind_offshore_mw - solar_mw AS residual_derived_mw,
residual_published_mw,
(load_mw - wind_onshore_mw - wind_offshore_mw - solar_mw) - residual_published_mw AS residual_gap_mw,
share_generation_published_pct,
100 * renewable_mw / nullif(generation_mw, 0) AS share_generation_derived_pct,
(100 * renewable_mw / nullif(generation_mw, 0)) - share_generation_published_pct AS share_generation_gap_pp,
share_load_published_pct,
100 * renewable_mw / nullif(load_mw, 0) AS share_load_derived_pct,
(100 * renewable_mw / nullif(load_mw, 0)) - share_load_published_pct AS share_load_gap_pp,
price_eur_mwh,
price_unit,
gap_reason
FROM intervals;
COPY (
SELECT country, bidding_zone, unix_seconds, ts_utc, ts_local, local_date,
load_mw, solar_mw, wind_onshore_mw, wind_offshore_mw, waste_mw,
renewable_mw, generation_mw, residual_derived_mw, residual_published_mw, residual_gap_mw,
share_generation_published_pct, share_generation_derived_pct, share_generation_gap_pp,
share_load_published_pct, share_load_derived_pct, share_load_gap_pp,
price_eur_mwh, price_unit, gap_reason
FROM mart
ORDER BY country, unix_seconds
) TO '{{ outputFiles.intervals }}' (FORMAT PARQUET);
COPY (
SELECT country,
bidding_zone,
local_date,
count(*) AS intervals,
count(*) FILTER (WHERE gap_reason IS NULL) AS complete_intervals,
count(*) FILTER (WHERE gap_reason IS NOT NULL) AS gap_intervals,
round(sum(renewable_mw) FILTER (WHERE gap_reason IS NULL) * 0.25, 3) AS renewable_mwh,
round(sum(generation_mw) FILTER (WHERE gap_reason IS NULL) * 0.25, 3) AS generation_mwh,
round(sum(load_mw) FILTER (WHERE gap_reason IS NULL) * 0.25, 3) AS load_mwh,
round(avg(share_generation_derived_pct) FILTER (WHERE gap_reason IS NULL), 2) AS mean_renewable_share_generation_pct,
round(avg(share_load_derived_pct) FILTER (WHERE gap_reason IS NULL), 2) AS mean_renewable_share_load_pct,
round(min(price_eur_mwh) FILTER (WHERE gap_reason IS NULL), 2) AS min_price_eur_mwh,
round(max(price_eur_mwh) FILTER (WHERE gap_reason IS NULL), 2) AS max_price_eur_mwh,
count(*) FILTER (WHERE gap_reason IS NULL AND price_eur_mwh < 0) AS negative_price_intervals,
round(max(abs(share_generation_gap_pp)) FILTER (WHERE gap_reason IS NULL), 4) AS max_share_generation_gap_pp,
round(max(abs(share_load_gap_pp)) FILTER (WHERE gap_reason IS NULL), 4) AS max_share_load_gap_pp,
round(max(abs(residual_gap_mw)) FILTER (WHERE gap_reason IS NULL), 4) AS max_residual_gap_mw
FROM mart
GROUP BY country, bidding_zone, local_date
ORDER BY country, local_date
) TO '{{ outputFiles.daily_summary }}' (HEADER, DELIMITER ',');
WITH ordered AS (
SELECT country,
bidding_zone,
unix_seconds - lag(unix_seconds) OVER (PARTITION BY country, bidding_zone ORDER BY unix_seconds) AS step
FROM mart
),
bounds AS (
SELECT
count(*) AS intervals,
count(DISTINCT country) AS markets,
count(*) FILTER (WHERE gap_reason IS NOT NULL) AS gap_rows,
round(max(abs(share_generation_gap_pp)) FILTER (WHERE gap_reason IS NULL), 4) AS max_share_generation_gap_pp,
round(max(abs(share_load_gap_pp)) FILTER (WHERE gap_reason IS NULL), 4) AS max_share_load_gap_pp,
round(max(abs(residual_gap_mw)) FILTER (WHERE gap_reason IS NULL), 4) AS max_residual_gap_mw,
count(*) FILTER (WHERE gap_reason IS NULL AND price_eur_mwh < 0) AS negative_price_intervals,
round(sum(renewable_mw) FILTER (WHERE gap_reason IS NULL) * 0.25, 1) AS renewable_mwh,
round(sum(load_mw) FILTER (WHERE gap_reason IS NULL) * 0.25, 1) AS load_mwh,
round(min(price_eur_mwh) FILTER (WHERE gap_reason IS NULL), 2) AS min_price_eur_mwh,
round(max(price_eur_mwh) FILTER (WHERE gap_reason IS NULL), 2) AS max_price_eur_mwh,
count(DISTINCT price_unit) FILTER (WHERE gap_reason IS NULL) AS price_units
FROM mart
),
steps AS (
SELECT count(*) FILTER (WHERE step IS NOT NULL AND step <> 900) AS bad_steps
FROM ordered
),
per_market AS (
SELECT country,
min(local_date) AS first_day,
max(local_date) AS last_day,
count(DISTINCT local_date) AS local_days,
strftime(arg_min(ts_local, unix_seconds), '%H:%M') AS first_clock,
strftime(arg_max(ts_local, unix_seconds), '%H:%M') AS last_clock
FROM mart
GROUP BY country
),
coverage AS (
SELECT count(*) AS markets_covering
FROM per_market
WHERE first_day = DATE '{{ outputs.resolve_window.values.start_date }}'
AND last_day = DATE '{{ outputs.resolve_window.values.end_date }}'
AND local_days = date_diff('day', DATE '{{ outputs.resolve_window.values.start_date }}', DATE '{{ outputs.resolve_window.values.end_date }}') + 1
AND first_clock = '00:00'
AND last_clock = '23:45'
),
roll AS (
SELECT country,
round(avg(share_generation_derived_pct), 1) AS share_pct,
count(*) FILTER (WHERE price_eur_mwh < 0) AS negative_price_intervals
FROM mart
WHERE gap_reason IS NULL
GROUP BY country
),
rolled AS (
SELECT coalesce(string_agg(country || '=' || share_pct || '% neg=' || negative_price_intervals, ', ' ORDER BY country), '') AS rollup
FROM roll
)
SELECT
'{{ outputs.resolve_window.values.start_date }}' AS start_date,
'{{ outputs.resolve_window.values.end_date }}' AS end_date,
b.markets,
c.markets_covering,
b.intervals,
b.gap_rows,
s.bad_steps,
b.max_share_generation_gap_pp,
b.max_share_load_gap_pp,
b.max_residual_gap_mw,
b.negative_price_intervals,
b.renewable_mwh,
b.load_mwh,
b.min_price_eur_mwh,
b.max_price_eur_mwh,
b.price_units,
r.rollup,
CASE
WHEN b.intervals = 0
OR b.markets <> 2
OR c.markets_covering <> 2
OR b.gap_rows > {{ inputs.max_missing_intervals }}
OR s.bad_steps > 0
OR b.price_units <> 1
OR b.max_share_generation_gap_pp IS NULL
OR b.max_share_load_gap_pp IS NULL
OR b.max_residual_gap_mw IS NULL
OR b.max_share_generation_gap_pp > {{ inputs.share_tolerance_pp }}
OR b.max_share_load_gap_pp > {{ inputs.share_tolerance_pp }}
OR b.max_residual_gap_mw > {{ inputs.residual_tolerance_mw }}
THEN 'FAIL'
ELSE 'PASS'
END AS gate
FROM bounds b, steps s, coverage c, rolled r;
- id: quality_ok
type: io.kestra.plugin.core.flow.If
description: Accept the window only when both markets cover every Berlin day and
the derived shares and residual load match the published series. A
failed window does not move the KV marker.
condition: "{{ outputs.build_mart.outputs[0].row.gate == 'PASS' }}"
then:
- id: remember_window
type: io.kestra.plugin.core.kv.Set
description: Marker for the next run. Written only after the reconciliation gate
passes.
key: "energy_charts_share_price_{{ inputs.country_1 }}_{{ inputs.country_2 }}_{{
inputs.zone_1 }}_{{ inputs.zone_2 }}"
value: "{{ outputs.build_mart.outputs[0].row.start_date }}:{{
outputs.build_mart.outputs[0].row.end_date }}:{{
outputs.build_mart.outputs[0].row.intervals }}"
- id: log_pass
type: io.kestra.plugin.core.log.Log
message: "Energy-Charts mart passed. window={{
outputs.build_mart.outputs[0].row.start_date }}..{{
outputs.build_mart.outputs[0].row.end_date }} previous={{
outputs.previous_window.value ?? 'none' }} markets={{
outputs.build_mart.outputs[0].row.markets }} intervals={{
outputs.build_mart.outputs[0].row.intervals }} gaps={{
outputs.build_mart.outputs[0].row.gap_rows }} bad_steps={{
outputs.build_mart.outputs[0].row.bad_steps }} share_gap_pp={{
outputs.build_mart.outputs[0].row.max_share_generation_gap_pp }}
load_share_gap_pp={{
outputs.build_mart.outputs[0].row.max_share_load_gap_pp }}
residual_gap_mw={{
outputs.build_mart.outputs[0].row.max_residual_gap_mw }}
negative_prices={{
outputs.build_mart.outputs[0].row.negative_price_intervals }}
renewable_mwh={{ outputs.build_mart.outputs[0].row.renewable_mwh
}} load_mwh={{ outputs.build_mart.outputs[0].row.load_mwh }}
price_eur={{ outputs.build_mart.outputs[0].row.min_price_eur_mwh
}}..{{ outputs.build_mart.outputs[0].row.max_price_eur_mwh }}
rollup={{ outputs.build_mart.outputs[0].row.rollup }}"
else:
- id: fail_quality
type: io.kestra.plugin.core.execution.Fail
errorMessage: "Energy-Charts reconciliation failed. window={{
outputs.build_mart.outputs[0].row.start_date }}..{{
outputs.build_mart.outputs[0].row.end_date }} markets={{
outputs.build_mart.outputs[0].row.markets }} covering={{
outputs.build_mart.outputs[0].row.markets_covering }} intervals={{
outputs.build_mart.outputs[0].row.intervals }} gaps={{
outputs.build_mart.outputs[0].row.gap_rows }} bad_steps={{
outputs.build_mart.outputs[0].row.bad_steps }} share_gap_pp={{
outputs.build_mart.outputs[0].row.max_share_generation_gap_pp }}
load_share_gap_pp={{
outputs.build_mart.outputs[0].row.max_share_load_gap_pp }}
residual_gap_mw={{
outputs.build_mart.outputs[0].row.max_residual_gap_mw }}
tolerance_pp={{ inputs.share_tolerance_pp }}
residual_tolerance_mw={{ inputs.residual_tolerance_mw }}
missing_budget={{ inputs.max_missing_intervals }} price_units={{
outputs.build_mart.outputs[0].row.price_units }}."
else:
- id: fail_inputs
type: io.kestra.plugin.core.execution.Fail
errorMessage: "Countries must be distinct lowercase codes, zones must look like
DE-LU or FR, and dates must be auto or YYYY-MM-DD with start on or
before end. Waste fraction must be 0 to 1. Got countries={{
inputs.country_1 }},{{ inputs.country_2 }} zones={{ inputs.zone_1
}},{{ inputs.zone_2 }} start={{ inputs.start_date }} end={{
inputs.end_date }}."
outputs:
- id: summary
type: JSON
value: "{{ outputs.build_mart.outputs[0].row }}"
description: Reconciliation row. gate is PASS or FAIL.
- id: intervals
type: FILE
value: "{{ outputs.build_mart.outputFiles.intervals }}"
description: Parquet of quarter-hours with generation, derived and published
shares, residual load, and the day-ahead price.
- id: daily_summary
type: FILE
value: "{{ outputs.build_mart.outputFiles.daily_summary }}"
description: CSV of one row per market and Berlin day, with energy, mean
renewable share, price range, and the largest gaps.
Energy-Charts publishes 15-minute generation and day-ahead prices. No API key. This flow loads two markets, rebuilds renewable share and residual load in DuckDB, and fails when they disagree with the published series.
morning_market_refresh (io.kestra.plugin.core.trigger.Schedule) runs at 07:10 Europe/Berlin and does not replay a missed run.inputs_ok (io.kestra.plugin.core.flow.If) checks distinct country codes, zones, and auto or YYYY-MM-DD dates.resolve_window (io.kestra.plugin.core.output.OutputValues) freezes the Berlin dates. auto ends two days before the run.previous_window (io.kestra.plugin.core.kv.Get) reads the last good window.fetch_markets (io.kestra.plugin.core.flow.Parallel) downloads generation and price for both markets.build_mart (io.kestra.plugin.jdbc.duckdb.Queries) counts hydro, biomass, solar, wind, and half of waste as renewable. Residual load is load minus wind and solar.quality_ok (io.kestra.plugin.core.flow.If) fails when a market is short or a gap exceeds tolerance. Otherwise remember_window stores the window and log_pass prints the rollup.api.energy-charts.info. Prices are SMARD data under CC BY 4.0.auto dates, and waste fraction 0.5.intervals and daily_summary. The schedule waits for 07:10 Europe/Berlin.Check an index's ISM policy attachment through the ISM Explain API, alert Slack on a gap or an unreachable index, and optionally attach the expected policy with the ISM Add Policy API.
Put a JSON settings document into OpenSearch under a known key, Get it back, and log a field from the returned document.
Search OpenAlex for related scholarly works, shape the response with DuckDB, and export a CSV.
A weekly Request task deletes the app-logs index dated thirty days before the run and confirms the deletion in Discord with the HTTP status.
An hourly size-zero OpenSearch search counts 5xx documents, and an If gate alerts Discord and fails the execution when a threshold is crossed.
A size-zero OpenSearch search counts yesterday's level ERROR log documents with date math and posts the total to Slack every morning.
