Custom CloudWatch dimensions for datomic.ion.cast/metrics

Would it be possible to allow specifying custom dimensions for CloudWatch metrics?

According to the current documentation - Monitoring Ions | Datomic -, only name, value and units are supported.

We would like to add a customer reference dimension to our metrics too.

Currently we are using the AWS API directly - via the Cognitect AWS API Clojure lib -, but it means we have to get the Datomic system name and the CloudFormation stack name of the compute group ourselves (and we are not sure what’s the official way to obtain those).

Here is a rough example of what we are doing now:

  (defn xxx-count! [customer-id]
    (let [system-name (:datomic/system-name (ion/get-env))
          stack (:deployment-group (ion/get-app-info))]
      (req!
        {:api        :monitoring,
         :op         :PutMetricData,
         :Namespace  "DatomicCloud",
         :MetricData [{:Unit       "Count",
                       :MetricName "<OurCustomMetricName>",
                       :Value      "1",
                       :Dimensions [{:Name  "customer-ref"
                                     :Value (util/customer-id->ref customer-id)}
                                    {:Name "system" :Value system-name}
                                    {:Name "stack" :Value stack}]}]})

and this is what i would wish for (again, just roughly):

  (cast/metric
    {:name             :OurCustomMetricName
     :value            1
     :units            :count
     :extra-dimensions {:customer-ref (util/customer-id->ref customer-id)}})

I’m not sure if the order of the dimensions matter.

If we could get the stack name and the datomic system name easily (both locally and remotely, which means the stack name should be probably the ion app name from the ion-config.edn), then i wouldn’t miss this feature so much from the cast/metrics function.

1 Like

I was thinking a bit more about this problem.
Would it make sense if the get-app-info (Ions Reference | Datomic) function would also return the Datomic system name?

That way we can rely on built-in ion library functionality to cast custom metrics.
Currently I had to weave in the system name into the env-map of the query group stack parameters, something like this:

{:stack/params
 (merge
   {:SystemName      (:datomic/system-name datomic-system)
    :ApplicationName (:datomic/app-name query-group)
    :EnvironmentMap  (pr-str
                       (merge
                         (select-keys query-group
                                      [:env/owner
                                       :stage/name])

                         ;; Needed as a dimension for custom CloudWatch metrics:
                         (select-keys datomic-system
                                      [:datomic/system-name])))

    :NodePolicyArn   (str "arn:aws:iam::" (:aws/account datomic-system)
                          ":policy/"
                          (str- stack-name "NodePolicy"))})}

We could get rid of the (select-keys datomic-system [:datomic/system-name]) part, if get-app-info or some other built-in solution could provide the Datomic system name.
Is it available as an env var maybe?