Metric
Metric
Section titled “Metric”Stores a collected server metric data point.
Fields
Section titled “Fields”Metric is a multi-variant object: each instance has an @type discriminator selecting one of the variants below, and each variant carries its own set of fields.
@type: "Counter"
Section titled “@type: "Counter"”Counter metric
Type:
UnsignedInt· default:0Count associated with the metric
metric
Section titled “metric”Type:
MetricType· requiredMetric event type
timestamp
Section titled “timestamp”Type:
UTCDateTime· requiredTimestamp of the metric entry
@type: "Gauge"
Section titled “@type: "Gauge"”Gauge metric
Type:
UnsignedInt· default:0Count associated with the metric
metric
Section titled “metric”Type:
MetricType· requiredMetric event type
timestamp
Section titled “timestamp”Type:
UTCDateTime· requiredTimestamp of the metric entry
@type: "Histogram"
Section titled “@type: "Histogram"”Histogram metric
Type:
UnsignedInt· default:0Value associated with the metric
Type:
UnsignedInt· default:0Sum associated with the metric
metric
Section titled “metric”Type:
MetricType· requiredMetric event type
timestamp
Section titled “timestamp”Type:
UTCDateTime· requiredTimestamp of the metric entry
JMAP API
Section titled “JMAP API”The Metric object is available via the urn:stalwart:jmap capability.
x:Metric/get
Section titled “x:Metric/get”This is a standard Foo/get method as defined in RFC 8620, Section 5.1.
This method requires the sysMetricGet permission.
curl -X POST https://mail.example.com/api \ -H 'Authorization: Bearer $TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "methodCalls": [ [ "x:Metric/get", { "ids": [ "id1" ] }, "c1" ] ], "using": [ "urn:ietf:params:jmap:core", "urn:stalwart:jmap" ] }'x:Metric/set
Section titled “x:Metric/set”This is a standard Foo/set method as defined in RFC 8620, Section 5.3.
Supports create, update, and destroy operations in a single call.
Create
Section titled “Create”This operation requires the sysMetricCreate permission.
curl -X POST https://mail.example.com/api \ -H 'Authorization: Bearer $TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "methodCalls": [ [ "x:Metric/set", { "create": { "new1": { "@type": "Counter" } } }, "c1" ] ], "using": [ "urn:ietf:params:jmap:core", "urn:stalwart:jmap" ] }'Update
Section titled “Update”This operation requires the sysMetricUpdate permission.
curl -X POST https://mail.example.com/api \ -H 'Authorization: Bearer $TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "methodCalls": [ [ "x:Metric/set", { "update": { "id1": { "count": 0 } } }, "c1" ] ], "using": [ "urn:ietf:params:jmap:core", "urn:stalwart:jmap" ] }'Destroy
Section titled “Destroy”This operation requires the sysMetricDestroy permission.
curl -X POST https://mail.example.com/api \ -H 'Authorization: Bearer $TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "methodCalls": [ [ "x:Metric/set", { "destroy": [ "id1" ] }, "c1" ] ], "using": [ "urn:ietf:params:jmap:core", "urn:stalwart:jmap" ] }'x:Metric/query
Section titled “x:Metric/query”This is a standard Foo/query method as defined in RFC 8620, Section 5.5.
This method requires the sysMetricQuery permission.
curl -X POST https://mail.example.com/api \ -H 'Authorization: Bearer $TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "methodCalls": [ [ "x:Metric/query", { "filter": {} }, "c1" ] ], "using": [ "urn:ietf:params:jmap:core", "urn:stalwart:jmap" ] }'stalwart-cli wraps the same JMAP calls. See the CLI reference for installation, authentication, and general usage.
stalwart-cli get Metric id1Create
Section titled “Create”stalwart-cli create Metric/Counterstalwart-cli query MetricUpdate
Section titled “Update”stalwart-cli update Metric id1 --field count=0Delete
Section titled “Delete”stalwart-cli delete Metric --ids id1