Skip to content

Commit

Permalink
Merge pull request #96 from embrace-io/sleira/delay-for-mimir-daily-m…
Browse files Browse the repository at this point in the history
…etrics

Improve documentation for Metrics API
  • Loading branch information
santileira authored Dec 5, 2024
2 parents 899a369 + 90f3646 commit 9c96a7e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 63 deletions.
5 changes: 2 additions & 3 deletions docs/custom-metrics-api/supported_metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_position: 1

# Supported Metrics

Global filters and global group bys are available to use on all the metrics.
Global filters and global group bys are available to use on all the metrics.

- Global filters: app_version, country, model, os_major_version and os_version.
- Global group bys: app_version, country, os_major_version, os_version and top_n_market_name.
Expand All @@ -31,7 +31,6 @@ The following metrics are supported as Custom Metrics. Metrics with the suffix "

:::info

1. Refer to this [documentation](/embrace-api/supported_metrics_and_queries/#dimension-reduction---other)
to understand how `top_n` dimensions work.
1. Refer to this [documentation](/embrace-api/supported_metrics_and_queries/#dimension-reduction---other) to understand how `top_n` dimensions work.
2. You can also pull the latest set of supported metrics directly from the [API](/custom-metrics-api/#get-metrics-and-parameters-supported).
:::
18 changes: 11 additions & 7 deletions docs/embrace-api/grafana_integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Learn about the Embrace API to pull data
sidebar_position: 1
---

# Metrics API Grafana Integration
# Grafana Integration

## Prerequisites

Expand All @@ -14,11 +14,15 @@ sidebar_position: 1
## Setting Up Embrace as a Data Source

Follow these steps to add Prometheus as a data source in the Grafana dashboard:
1. Click the gear icon to go to the Configurations page.
2. Click on "Add data source" and select Prometheus.
3. Name your source "embrace-metrics-api" and set the following fields:
- `URL`: `https://api.embrace.io/metrics`
- Under `Custom HTTP Headers`, add a header with a name `Authorization` and use `Bearer <YOUR_API_TOKEN>` as your token string. For example, if your API token is `e2d75f07a40843f0b8a53d1e3201edba`, your token string should be `Bearer e2d75f07a40843f0b8a53d1e3201edba`.
1. Click the "Open Menu" icon to go to the "Connections -> Data sources" page.
1. Click the "Add new data source" button on the top right page and select "Prometheus".
3. Configure it with the following fields:
- Name: `embrace-metrics-api`.
- Under "Connection" section, set "Prometheus server URL": `https://api.embrace.io/metrics`.
- Under "Authentication" section, click the button "Add header":
- Header: `Authorization`, Value: `Bearer <YOUR_API_TOKEN>` as your token string. For example, if your API token is `e2d75f07a40843f0b8a53d1e3201edba`, your token string should be `Bearer e2d75f07a40843f0b8a53d1e3201edba`.

<img src={require('@site/static/images/metrics-api/grafana.png').default} alt="Grafana Data Source" />

## Importing Dashboard JSON

Expand All @@ -30,7 +34,7 @@ Add a new panel and set the visualization to "Time series".

<img src={require('@site/static/images/metrics-api/timeseries_visualization.png').default} alt="Image showing Grafana timeseries visualization" />

Set the data source to "embrace-metrics-api:. In the "Query options" section set the "Min interval". Currently only the following intervals are supported: 1m, 5m, 10m, 15m, 30m, 1hr, and 1d. **Keep in mind that Prometheus only supports 11,000 points per time series.**
Set the data source to "embrace-metrics-api": In the "Query options" section set the "Min interval". Currently only the following intervals are supported: 1m, 5m, 10m, 15m, 30m, 1hr, and 1d. **Keep in mind that Prometheus only supports 11,000 points per time series.**

<img src={require('@site/static/images/metrics-api/query_options.jpg').default} alt="Grafana timeseries visualization" />

Expand Down
2 changes: 1 addition & 1 deletion docs/embrace-api/metrics-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_position: 5

# Metrics migration (2023-10-23)

Embrace is updating its beta Metrics API to support interoperability. This means all metrics, both the pre-built or "Standard" and Custom Metrics, can be combined in any analyses you plan on doing. Sum across time-ranges and other dimensions, compare one Metric with another, or use multiple metrics to compute relevant rates.
Embrace is updating its beta Metrics API to support interoperability. This means all metrics, both the pre-built Standard Metrics and your Custom Metrics, can be combined in any analyses you plan on doing. Sum across time-ranges and other dimensions, compare one Metric with another, or use multiple metrics to compute relevant rates.

Unfortunately this means some metrics will no longer be supported, and others will be brought into our standardized data environment and naming conventions.

Expand Down
91 changes: 39 additions & 52 deletions docs/embrace-api/supported_metrics_and_queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ description: Learn about the metrics and queries supported by the Embrace API
sidebar_position: 3
---

# Metrics API Supported Metrics
# Supported Metrics

## Standard Metrics
The following metrics are supported. Metrics with the suffix "_total" are gauges.

The following metrics are supported as Standard Metrics. Metrics with the suffix "_total" are gauges.
To query your desired unit, simply prefix the metric name with the unit, eg: `daily_crashes_total`, `hourly_my_custom_sessions_total` and
`five_minute_sessions_total`.

## Standard

To query your desired unit, simply prefix the metric name with the unit, eg: `daily_crashes_total`
or `five_minute_sessions_total`.

| Metric | Description | Filters | Time granularity |
|----------------|------------------------|---------------------------------------|----------------------------|
Expand Down Expand Up @@ -44,76 +45,62 @@ However, we strongly recommend transitioning to the new metrics to ensure a cons
| crashes_total_deprecated | Number of crashes | app_version, os_version | five_minute, hourly, daily |
| sessions_by_device_total_deprecated | Number of sessions grouped by device model | app_version, device_model, os_version | hourly, daily |
| sessions_total_deprecated | Number of sessions | app_version, os_version | five_minute, hourly, daily |
| users_deprecated | Number of unique users | app_version, os_version | hourly, daily |



### Dimension reduction - "Other"

To reduce storage costs with various observability platforms (eg Datadog), Embrace Metrics examine high cardinality dimensions for consolidation.
| users_deprecated | Number of unique users | app_version, os_version | hourly, daily | Metrics

#### Device Models
There are over 40,000 unique device models on the Android operating system. The bottom 39,000 models account for ~30% of data typically. Aside from being expensive to store this many unique values, it is also unwieldy to visualize or review!

<img src={require('@site/static/images/embrace-api/device_other.png').default} alt="Chart showing data by device ranking" />

Currently, we roll together these long-tail device models into an "other" value.
## Custom Metrics

### Sample Queries
Refer to this [documentation](/custom-metrics-api/supported_metrics.md) to know the supported custom metrics.

#### Sessions Grouped by App Version
## Sample PromQL queries

* Sessions grouped by devices for a given app version
```promql
sum(daily_sessions_total{app_id="<app ID>"}) by (app_version)
sum(daily_sessions_total{app_id="<app ID>", app_version="1.2.3"}) by (device_model)
```

#### Sessions Grouped by Devices

* Percentage of crash free sessions by devices.
```promql
sum(daily_sessions_total{app_id="<app ID>"}) by (device_model)
1 - sum(hourly_crashes_total{app_id="$app_id"}) by (device_model) / sum(hourly_sessions_total{app_id="$app_id"}) by (device_model) * 100
```

#### Sessions Grouped by Devices for a Given App Version

* Percentage of crash sessions by devices.
```promql
sum(daily_sessions_total{app_id="<app ID>", app_version="1.2.3"}) by (device_model)
sum(hourly_crashes_total{app_id="$app_id"}) by (device_model) / sum(hourly_sessions_total{app_id="$app_id"}) by (device_model) * 100
```

#### Percentage of crash free sessions
Also, you can pull data for one, multiple, or all of your organization's apps in a single query.

* To pull for a single app, include the `app_id` in the PromQL filter,
```promql
(1 - (sum(hourly_crashes_total{app_id="$app_id"}) / sum(hourly_sessions_total{app_id="$app_id"}) )) * 100
sum(hourly_custom_metric_sessions_total{app_id="a1b2C3"})
```

#### Percentage of crash free sessions by Devices

* To pull for multiple apps, include a pipe-delimited array in the filter,
```promql
1 - sum(hourly_crashes_total{app_id="$app_id"}) by (device_model) / sum(hourly_sessions_total{app_id="$app_id"}) by (device_model) * 100
sum(hourly_custom_metric_sessions_total{app_id=~"a1b2C3|Z9Y8x7"})
```

#### Percentage of crash sessions by Devices

* To pull for all apps, do not include any app ID in the filter,
```promql
sum(hourly_crashes_total{app_id="$app_id"}) by (device_model) / sum(hourly_sessions_total{app_id="$app_id"}) by (device_model) * 100
sum(hourly_custom_metric_sessions_total{})
```
## Custom Metrics

Users may request Custom Metrics via their Customer Success Manager. These will be available via the Metrics API and can
also be forwarded to your organization's [observability platform of choice](/data-destinations).
## Dimension reduction - "Other"

### Sample Queries
To reduce storage costs with various observability platforms (eg Datadog), Embrace Metrics examine high cardinality dimensions for consolidation.

You can pull data for one, multiple, or all of your organization's apps in a single query.
### Device Models
There are over 40,000 unique device models on the Android operating system. The bottom 39,000 models account for ~30% of data typically. Aside from being expensive to store this many unique values, it is also unwieldy to visualize or review!

<img src={require('@site/static/images/embrace-api/device_other.png').default} alt="Chart showing data by device ranking" />

Currently, we roll together these long-tail device models into an "other" value.

## Metrics Availability

This is the time when the metrics will be available to consume in the Embrace Metrics API.

- Five minute metrics will be available to consume in about 4 minutes. Data point calculated at `2024-11-25 00:05:00` will be available to consume after `2024-11-25 00:10:00`.
- Hourly metrics will be available to consume in about 15 minutes. Data point calculated at `2024-11-25 01:00:00` will be available to consume after `2024-11-25 01:14:00`.
- Daily metrics will be available to consume in about 14 hours. Data point calculated at `2024-11-25 00:00:00` will be available to consume after `2024-11-25 14:00:00`.

* To pull for a single app, include the `app_id` in the PromQL filter,
```promql
sum(hourly_anr_free_sessions{app_id="a1b2C3"})
```
* To pull for multiple apps, include a pipe-delimited array in the filter,
```promql
sum(hourly_crashes_by_tag{app_id=~"a1b2C3|Z9Y8x7"}) by (tag_value)
```
* To pull for all apps, do not include any app ID in the filter,
```promql
sum(five_minute_network_requests_fails_by_domain{}) by (domain)
```
Binary file added static/images/metrics-api/grafana.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9c96a7e

Please sign in to comment.