https://infracost.io logo
#help
Title
# help
w

wooden-smartphone-11475

07/15/2023, 5:18 PM
Hello folks! Loving the product very much! Can someone point me where do I find the available
productName
values I can pass in this query:
Copy code
query {
  products(
    filter: {
      vendorName: "azure",
      service: "Virtual Machines",
      productFamily: "Compute",
      region: "centralus",
      attributeFilters: [
        { key: "skuName", value: "DS2 v2" }
        { key: "productName", value:"Virtual Machines DSv2 Series Windows"}
      ]
    },
  ) {
    prices(
      filter: {
        purchaseOption: "Consumption",
        unit: "1 Hour"
      },
    ) { USD }
  }
}
I can get the
skuName
by running the az cli:
Copy code
az vm list-sizes -l <location>
and then I get this list where I can see the name but no mention of `productName`:
Copy code
{
	'maxDataDiskCount': 64,
	'memoryInMb': 5836800,
	'name': 'Standard_M208ms_v2',
	'numberOfCores': 208,
	'osDiskSizeInMb': 1047552,
	'resourceDiskSizeInMb': 4194304
}
Thanks a lot!!
w

white-airport-8778

07/15/2023, 6:33 PM
Hey Pavel, follow the contributing guide and it’ll show you how you can query the DB for available values, these come from the cloud vendors…
BTW, what’s your use-case with the Cloud Pricing API?
w

wooden-smartphone-11475

07/18/2023, 7:34 AM
Hi Ali! I want to add Infracost's pricing API data to my open source Cloud Management system: https://github.com/Trolley-MGMT/trolleymgmt I'd be glad to share with you more details if you'd like.
@white-airport-8778 I kinda got lost with graphQL schema and all. This is the first time I work with graphQL and not sure how to build a query to fetch all the available product names 😞
w

white-airport-8778

07/18/2023, 5:36 PM
@wooden-smartphone-11475 very cool! Your best bet is to query the Cloud Pricing API’s Postgres DB directly, see here for instructions and example queries: https://github.com/infracost/infracost/blob/master/contributing/add_new_resource_guide.md#price-search
w

wooden-smartphone-11475

07/18/2023, 6:49 PM
Can't find productName anywhere 😞 looked for it in the code as well and cannot find.. When I run the query like this:
Copy code
query {
  products(
    filter: {
      vendorName: "azure",
      service: "Virtual Machines",
      productFamily: "Compute",
      region: "centralus",
      attributeFilters: [
        { key: "skuName", value: "DS2 v2" }
      ]
    },
  ) {
    prices(
      filter: {
        purchaseOption: "Consumption",
        unit: "1 Hour"
      },
    ) { USD }
  }
}
I get 3 different values as opposed to this:
Copy code
query {
  products(
    filter: {
      vendorName: "azure",
      service: "Virtual Machines",
      productFamily: "Compute",
      region: "centralus",
      attributeFilters: [
        { key: "skuName", value: "DS2 v2" }
        { key: "productName", value:"Virtual Machines DSv2 Series Windows"}
      ]
    },
  ) {
    prices(
      filter: {
        purchaseOption: "Consumption",
        unit: "1 Hour"
      },
    ) { USD }
  }
}
with the
productName
key. I'd like to find in the code/db the source of these values for Azure. I just cannot find them. I will continue looking for it, thanks
Copy code
ERROR:  column "productName" does not exist
LINE 1: SELECT DISTINCT "service", "productName" FROM products WHERE...
                                   ^
HINT:  Perhaps you meant to reference the column "products.productHash". 

SQL state: 42703
Character: 28Query returned successfully in 160 msec.
When I am trying to run:
Copy code
SELECT DISTINCT "service", "productName" FROM products WHERE "vendorName" = 'azure';
w

white-airport-8778

07/18/2023, 6:53 PM
productName (alongside the skuName) is in
attributes
, try something like this
Copy code
SELECT DISTINCT "service", "productFamily", "attributes"->>'productName' AS productName, "attributes"->>'skuName' AS skuName FROM products WHERE "vendorName" = 'azure'
w

wooden-smartphone-11475

07/18/2023, 6:54 PM
checking
w

white-airport-8778

07/18/2023, 6:55 PM
in this doc, look for the section that talks about this query:
Copy code
Much better! Instead of hundreds of records, we reduced the search to four possibilities. But it is still unclear what exactly represents the service. The guess would be the last two rows, but it is uncertain. We need more information, and including the attributes column in the output may help.

.....

SELECT DISTINCT "service", "productFamily", "attributes" FROM products WHERE "vendorName" = 'aws' AND "service" = 'AWSTransfer' AND region = 'us-east-1';
w

wooden-smartphone-11475

07/18/2023, 7:28 PM
Ok, I run this query now:
Copy code
SELECT DISTINCT "service", "productFamily", "attributes"->>'productName' AS productName, "attributes"->>'skuName' AS skuName, "prices"
FROM products 
WHERE "vendorName" = 'azure' AND "attributes"->>'skuName' = 'DS2 v2';
And I am getting a lot of different prices responses (165) Is there a way to shorten them to 4 in accordance to the productNames I see in the DB?
sorry, I haven't touched SQL in like a decade now. Been 100% into NoSQL stuff 😄
w

white-airport-8778

07/18/2023, 7:40 PM
Maybe review the attributes column in the DB to see if there are any other properties that has the high-level name you want? e.g.
Copy code
SELECT DISTINCT "attributes"
FROM products 
WHERE "vendorName" = 'azure' AND "attributes"->>'skuName' = 'DS2 v2';
3 Views