Skip to content

Clarification on get_metric_range_data method #291

Description

@kev-pebble

I am querying the Prometheus Host. I specify the start, end time and chunksize as 1 hour. When querying the data between the start and end times with 1 hour chunksize, is the data returned aggregated sum by the hour or simply the value at the hourly timestamp? My metric is a counter metric like kepler_container_joules_total, so the returned values as cumulative totals at the specified hourly timestamps?

def query_data(victoria_db_url, start_time, end_time, metric_name=None):

    prom = PrometheusConnect(url=victoria_db_url, disable_ssl=True)
    
    # Run query
    result = prom.all_metrics()
    
    kepler_metrics = [metric for metric in result if 'kepler' in metric]
    
    # save dfs as list
    df_list = []

    # set default metric
    if metric_name == None:
        metric_name == "kepler_container_joules_total"
        
    # Query the data
    for metric in kepler_metrics:

        if metric == metric_name:
        
            #print(f"Metric: {metric}")
            data = prom.get_metric_range_data(
                                                metric_name=metric,
                                                start_time = start_time,
                                                end_time = end_time,
                                                chunk_size = timedelta(hours=1)
                                             )
            
            if data:
                # Convert the metric data to a DataFrame
                metric_df = MetricSnapshotDataFrame(data)
                # Append the DataFrame to the list
                df_list.append(metric_df)

    df_kepler = pd.concat(df_list, ignore_index=True)

    return df_kepler

Is there a way to get aggregate hourly power consumption without the cumulative / counter time series data?

@4n4nd

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions