Skip to content

Filter Support to Custom Queries #136

Open
@irynamill

Description

@irynamill

Hi,

I was wondering if there’s a way to apply filters to a custom query in azure-resourcemanager-exporter. Specifically, I’d like to refine the results of a query to include only specific resources based on certain conditions.

queries:
  - name: by_resourceId
    help: Costs by ResourceId
    filter: ???
    dimensions: [SubscriptionId, ResourceGroupName, ResourceType, ChargeType, PublisherType, ResourceId]
    granularity: None
    valueField: PreTaxCost
    timeFrames: [MonthToDate, YearToDate]

When I query the API directly, I am able to add filter in the dataset:

{
  "type": "Usage",
  "timeframe": "MonthToDate",
  "dataset": {
    "granularity": "None",
    "filter": {
      "dimenstions": {
        "name": "ResourceType",
        "operator": "In",
        "values": ["microsoft.storage/storageaccounts"]
      }
    },
    ...
    ...
  }
}

As far as I can see here https://github.com/webdevops/azure-resourcemanager-exporter/blob/main/config/config_cost.go#L18-L32 There is no possibility to add filter as of now? Is there any existing functionality for this that I have missed, or would it be possible to add filter support to custom queries in a future update? If so, could you provide some guidance on how this might be implemented?

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