-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
part:βWe need to figure out which part is affectedWe need to figure out which part is affectedpriority:βWe need to figure out how soon this should be addressedWe need to figure out how soon this should be addressedtype:enhancementNew feature or enhancement visitble to usersNew feature or enhancement visitble to users
Description
What's needed?
A data structure that can expose the metrics as well as the states per microgrid and component.
Proposed solution
Option to be discussed:
- Full (artificial) mapping from protobuf to Python datatype
- Helpers (such as namedtuples) to work
Use cases
Not only metrics, but also states, warnings and errors should be exposed.
Alternatives and workarounds
Any alternative ideas are welcome.
Additional context
As discussed in API usergroup meeting on 6th May 2024:
Currently, the ReportingApiClient only exposes MetricSamples using a namedtuple structure.
To additionally expose States:
- At any given timestamp, a component can have multiple states, such as
chargingandrelay_open - Practically, whenever you get a metric you can also get the states information
The example output structure from the protobuf is as follows with the entry point to the GRPC returning those messages.
> // Response containing historical microgrid component metrics in one or multiple microgrids
> //
> // Each microgrid's components are provided as timeseries data structures that encapsulate
> // metrics, bounds, errors and operational state and their associated timestamps for each component
> // within the specified time range.
> //
> // !!! example
> // Example output structure:
> // ```
> // microgrids: [
> // {
> // microgrid_id: 1,
> // components: [
> // {
> // component_id: 13,
> // metric_samples: [
> // /* list of metrics for multiple timestamps */
> // { sampled_at: "2023-10-01T00:00:00Z", metric: "DC_VOLTAGE_V", sample: {...}, bounds: {...} },
> // { sampled_at: "2023-10-01T00:00:00Z", metric: "DC_CURRENT_A", sample: {...}, bounds: {...} }
> // { sampled_at: "2023-10-01T00:05:00Z", metric: "DC_VOLTAGE_V", sample: {...}, bounds: {...} },
> // { sampled_at: "2023-10-01T00:05:00Z", metric: "DC_CURRENT_A", sample: {...}, bounds: {...} }
> // ],
> // states: [
> // /* list of states for multiple timestamps */
> // { sampled_at: "2023-10-01T00:00:13.12Z", states: [...], errors: [...], warnings: [...] },
> // { sampled_at: "2023-10-01T00:02:22.01Z", states: [...], errors: [...], warnings: [...] },
> // { sampled_at: "2023-10-01T00:05:02.32Z", states: [...], errors: [...], warnings: [...] },
> // ]
> // },
> // {
> // component_id: 243,
> // metric_samples: [ ... ],
> // states: [ ... ]
> // },
> // ]
> // },
> // {
> // microgrid_id: 2,
> // components: [ ... ]
> // }
> // ]
> // ```
To retrieve MetricSample information, we use the following helper in the ReportingApiClient:
MetricSample = namedtuple(
"MetricSample", ["timestamp", "microgrid_id", "component_id", "metric", "value"]
)
"""Type for a sample of a time series incl. metric type, microgrid and component ID
A named tuple was chosen to allow safe access to the fields while keeping the
simplicity of a tuple. This data type can be easily used to create a numpy array
or a pandas DataFrame.
"""
tiyash-basu-frequenz
Metadata
Metadata
Assignees
Labels
part:βWe need to figure out which part is affectedWe need to figure out which part is affectedpriority:βWe need to figure out how soon this should be addressedWe need to figure out how soon this should be addressedtype:enhancementNew feature or enhancement visitble to usersNew feature or enhancement visitble to users