Create
Create a billable metric
client.v1.billableMetrics.create(BillableMetricCreateParamsbody, RequestOptionsoptions?): dataIDBillableMetricCreateResponse
post/v1/billable-metrics/create
Creates a new Billable Metric.
Parameters
bodynamestringaggregation_keystringaggregation_typeunioncustom_fieldsRecord<string, string>event_type_filterEventTypeFiltergroup_keysarrayproperty_filtersarraysqlstringBillableMetricCreateParams
Returns
BillableMetricCreateResponse
import Metronome from '@metronome/sdk';
const client = new Metronome({
bearerToken: 'My Bearer Token',
});
const billableMetric = await client.v1.billableMetrics.create({
name: 'CPU Hours',
aggregation_key: 'cpu_hours',
aggregation_type: 'SUM',
event_type_filter: { in_values: ['cpu_usage'] },
group_keys: [['region'], ['machine_type']],
property_filters: [
{ name: 'cpu_hours', exists: true },
{ name: 'region', exists: true, in_values: ['EU', 'NA'] },
{ name: 'machine_type', exists: true, in_values: ['slow', 'fast'] },
],
});
console.log(billableMetric.data);
200 Example
{
"data": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
}