How to create a metric from console (without reprovisioning)


#1

Hi All,

How can I create a SimpleMetric from console? I would like to avoid re-provisioning while I’m testing.

I can see existing simple metrics in the via c3Grid(SimpleMetrics.fetch()) - so I tried this:

x = SimpleMetric.make(
      {
        "id": "EngineSpeed",
        "name": "EngineSpeed",
        "srcType": "SC2MeasurementSeries",
        "expression" : "max(normalized.data.values)"
      })

x.upsert();

It looks like any other simple metric when I refetch from SimpleMetric…, but when I try to use evalMetrics() on it, EngineSpeed is not recognized as a valid metric name. I heard another step might be required…

Thanks

Paul


#2

There may be a way to do this, but don’t. Every time you provision your metrics will disappear. Instead, for testing new metrics use evalMetricsWithMetadata


#3

found my answer: Upsert a metric in an environment

I should add that my previous manual upsert to SimpleMetric must be cleaned up first.

SimpleMetric.get("EngineSpeed").remove()

Then, do:

x = SimpleMetric.make(
      {
        "id": "EngineSpeed",
        "name": "EngineSpeed",
        "srcType": "SC2MeasurementSeries",
        "expression" : "max(normalized.data.values)"
      })


var v = MetadataStore.tag()
v.upsertSeedObjs([SimpleMetric.make(x)])

The metric works – I did first test with evalMetricsWithMetadata – and understand that when we provision, it will be lost unless I create it properly under seed/SimpleMetric

However, I’m trying to do some work with SomeType.getDistribution()… which requires a metric as input (by name) and doesnt give me an opportunity to define the metric in-line. So I just need a quick way to upsert a metric to play with it.