Skip to content

[Research] Cost Management Receiver #485

@constanca-m

Description

@constanca-m

This issue is to open the discussion on how we could get data for:

  • Resources costs
  • Savings recomendations
  • Forecast

The receiver (note: open to be a different component or to be integrated in an already existent component, but throughout this description I will write it as a receiver), would be a bit like:

receiver:
  costmanagement:
     # we could have different providers,
     # each would be implementing the same
     # interface
     provider: aws

Focusing a bit more on AWS, there are a few functions available on AWS SDK that we could use:

For the AWS use case in specific, it would have support for:

  • GetCostAndUsage function
  • GetCostForecast function
  • GetSavings*Recommendation functions

To help visualize, let's imagine the configuration for the function GetCostAndUsage and GetCostForecast:

receiver:
  costmanagement:
    provider: aws
    aws:
      # I did no research do see which fields are in common
      # between all three features, so I will only consider
      # the fields in common between forecast and usage under
      # this block.    
      billing: [optional] # the billing view arn    
      filters:
        - [list of expressions]
      granularity: DAILY
      poll_interval: 24h # when to make next request
      
      # This part applies especifically to the forecast.
      # Each common field can be overwritten if necessary.
      # See https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetCostForecast.html.
      forecast:
        filters:
          - [add extra filters]     
        metric: METRIC
        time:
          start: START
          end: END
          
      # This part applies especifically to the usage.
      # Each common field can be overwritten if necessary.
      # See https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetCostAndUsage.html
      usage:
        metrics:
          - [list of metrics]
        filters:
          - [add extra filters]
        group_by:
          - [add groups]
        time:
          start: START
          end: END

Example use case for us: we deploy this receiver in a collector (let's think of MOtel):

  • We have the receiver running and get data on how much the tagged hosted-otel-collector resources use.
  • We send this to elasticsearch exporter.
  • We could optionally then configure an alert on the Elasticsearch side.

Alternatives: There is another option to AWS Cost Explorer. We could use the AWS Pricing API. This is just the pricing of the costs, so for services that require payment according to the usage, we would have to get the usage metrics through cloudwatch metrics (usage * price per usage). This way, the delay wouldn't be so long (AWS Cost explorer is up to 24h delay), but this is much more work to build. Then it would also have no savings recommendation, I believe that's unique to the cost explorer.

What about the current AWS Cloudwatch metrics?: For AWSCloudwatch to get estimated costs, it requires: first to set up billing alarms, can only split by service, no recommendation for savings possible. So it is much more limited.

What about adding this as a functionality that is part of the ECF? I can see a few issues with this:

  • Big con: It would force every person that wants to use the cost receiver, to also deploy ECF. ECF might have functionalities that don't matter at all for this use case.
  • We would have to manually configure the report, I think.
  • There is no reason to deploy in AWS lambda, if we can authenticate through AWS SDK. Then we can deploy this receiver wherever we want.

How could we then use this with ECF if we wanted?
I think we could do it this way:

flowchart LR
    subgraph "Cost Management Pipeline"
        A[Cost Receiver] --> B[Processor] --> C[S3 Exporter]
    end

    C -. "put object notifies" .-> D[ECF Receiver]

    subgraph "Event Processing Pipeline"
        direction TB
        D --> E[Elasticsearch Exporter]
    end
Loading

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions