Build an Apple Health Dashboard with Grafana

Sean WadeUpdated 8 min read

Already running Grafana? Install the PulsHealth iPhone app, pair it with the reference stack, and import Yesterday in Apple Health. This three-panel dashboard reads steps, sleep and workouts from the synced PostgreSQL database.

Connect your existing Grafana

  1. On your iPhone, grant access to Steps, Sleep and Workouts. Enable the all-device daily step sum, apply the configuration, and run a sync covering a completed day with known records.
  2. In Grafana's Connections → Data sources, add PostgreSQL. Use database postgres, user grafana, and the stack's GRAFANA_DB_PASSWORD. Select PostgreSQL 17 and enable TimescaleDB. Use db:5432 on the stack's Docker network, or 127.0.0.1:5432 from Grafana running directly on the database host. A different container has its own loopback address. For a remote Grafana, use a private route and verified TLS. The stock database port binds to loopback. Click Save & test. The provisioned datasource uses UID puls-tsdb. If Grafana generated another UID, copy it from the end of the datasource settings URL and replace every puls-tsdb in the downloaded JSON with that UID.
  3. Open Dashboards → New → Import, upload the JSON, and select your account's reporting time zone in dashboard settings. Set User UUID to the account that received your phone's sync. This datasource can read multiple people's rows. Restrict dashboard and datasource access to trusted operators.
  4. Leave the range on Yesterday. Compare the step count with Health and one workout duration with Fitness. The sleep panel measures time inside the selected calendar day covered by any asleep interval, merging overlaps across devices. Apple's overnight view can include hours from the preceding date. An empty sleep panel means missing coverage.
Yesterday in Apple Health displayed in Grafana with daily steps, recorded sleep and workout duration from synthetic records.
Open full-size image
The imported dashboard with synthetic records. The same panels read your own synced records after you select your account.

Explore the queries and sync coverage

This guide builds four Grafana panels from your synced Apple Health history: daily steps, workout durations, the calculation behind each step total, and time since the latest upload.

It uses the PulsHealth reference stack. The iPhone app reads Apple Health, the ingest service stores records in PostgreSQL with TimescaleDB, and Grafana queries the database through a read-only role.

Each panel answers a different question. Start by checking them against known records before adding more metrics.

Updated October 25, 2026: clarified account-calendar labels and simplified the validation notes. All four downloadable queries were rerun against a disposable PostgreSQL 17 fixture with the read-only Grafana role.

At a glance

Four panels, four different questions

Daily steps + provenance

  1. Daily summary
  2. Value and calculation source
  3. Compare a known day

Keep aggregate versus rollup visible beside the daily value.

Recorded workout duration

  1. One workout record
  2. Duration in minutes
  3. One plotted point

A record is a session, not a continuous exercise signal.

Upload freshness

  1. Latest received batch
  2. Hours since receipt
  3. Check the target metric too

A fresh upload can contain old measurements. Receipt age is not a completeness score.

Panel reading guide for the downloadable dashboard. This is a schematic, not a Grafana screenshot or measured result.

Start with a working private stack

Follow the maintained server setup guide for installation, phone pairing, credentials, and network configuration. Let the phone sync some records before designing panels. Grafana cannot discover information that has not reached the database.

The reference stack already includes Grafana dashboards. This tutorial adds a smaller, editable dashboard so you can understand the queries and change them deliberately. You do not need a separate metrics service or another database.

Keep Grafana on a trusted private connection. Use its provisioned puls-tsdb PostgreSQL datasource, which connects as the grafana database role. Avoid connecting a dashboard as the database superuser. Grafana's own PostgreSQL setup guidance recommends restricting the datasource account to SELECT permissions.

Read-only does not mean private between viewers. The reference stack's Grafana role can read health records belonging to multiple users. A dashboard variable is a query filter, not an authorization boundary. Share access only with people entitled to use that datasource; use the account-aware PulsHealth viewer for a different access model.

Import the starter dashboard

Download dashboard.json, along with its README. The matching SQL templates are available separately for inspection.

In Grafana, open the dashboard import screen, upload the JSON, and save it with a name you recognize. The template references the existing puls-tsdb datasource UID. If you use a separately installed Grafana, configure an appropriate read-only PostgreSQL connection and change the dashboard's datasource references to match it.

Set User UUID to your existing PulsHealth user ID. The default is an all-zero placeholder and should return no records. Get the correct UUID from your own app or stack configuration; the template intentionally does not list everyone's names or email addresses.

Set the dashboard's display time zone to the selected account's reporting zone (users.time_zone, falling back to PULS_TIME_ZONE), and choose a range with known records. This is especially important for midnight daily points: a local-day timestamp displayed in another zone can appear on the preceding date.

The expected first result is straightforward:

PanelWhat you should see
Daily steps by provenanceDaily values, distinguished as aggregate or rollup
Hours since latest received batchA number when an upload arrived in the past 90 days
Recorded workout durationOne point per workout, in minutes
Daily step provenanceA table containing day, value, and calculation source
Layout reference showing four Grafana panels: daily steps, receipt age, six workout points, and a provenance table, all using synthetic data.
Open full-size image
Layout reference, not verification of the current queries: this earlier Grafana 13.2.3 capture uses synthetic September 1–14 data and predates the account-calendar update. The four-panel arrangement is unchanged. The all-zero user is a fixture placeholder; receipt age reflects capture time. Grafana can display longer workout durations in hours.

No data is a useful diagnostic result. Check the user, selected dates, sync coverage, and aggregate configuration before changing the query to accept unrelated rows.

Use daily summaries for daily steps

The tempting query sums every step sample by date. The problem is that an iPhone and Apple Watch can contribute overlapping records. A sum of all raw samples can become a sum of competing descriptions of the same activity.

PulsHealth's metric_daily view is designed for daily analysis. It prefers the canonical all-device daily HealthKit aggregate when available. Its cumulative-metric fallback uses the highest single-source daily sum rather than adding all sources together. These are different calculations, which is why the dashboard preserves the source column. Raw rollups use the account reporting calendar; phone aggregates with temporal context keep their recorded calendar day. Those can differ during travel. The full rules are in the database guide.

The essential query is:

SELECT day::timestamp AT TIME ZONE puls_user_time_zone(${user:sqlstring}::uuid) AS time,
       value, source AS metric
FROM metric_daily
WHERE identifier = 'HKQuantityTypeIdentifierStepCount'
  AND user_id = ${user:sqlstring}::uuid
  AND day >= ($__timeFrom()::timestamptz
              AT TIME ZONE puls_user_time_zone(${user:sqlstring}::uuid))::date
  AND day <= ($__timeTo()::timestamptz
              AT TIME ZONE puls_user_time_zone(${user:sqlstring}::uuid))::date
ORDER BY time

This is a Grafana SQL template, not SQL to paste unchanged into psql. Grafana substitutes the variable and time macros. Its query-editor documentation explains the macro expansion and Query Inspector.

The filter includes whole local calendar days intersecting the selected range. Selecting noon to noon does not divide a daily total into half-days. The current day can also be incomplete. Choose completed days when comparing totals, and check the provenance table when an aggregate becomes a fallback.

Only metrics with the appropriate configured sum or average series appear in this view. If steps are missing, verify that the phone's aggregate configuration includes the canonical daily all-device sum and that you applied it. A raw-sample sync alone does not guarantee the daily view is configured as intended.

Plot recorded workouts as individual events

Workout durations need a different representation. Each row is a session, so the template uses points rather than drawing a continuous signal between runs and walks:

SELECT start_ts AS time, duration_s / 60.0 AS minutes
FROM workouts
WHERE user_id = ${user:sqlstring}::uuid
  AND $__timeFilter(start_ts)
ORDER BY time

The time filter acts on the workout's start instant. A session that begins before the range and ends inside it is therefore excluded. The duration field is used directly; subtracting start from end can answer a different question when a session contains pauses.

This panel measures recorded workouts, not all exercise. Two recording apps can create different records for the same session, and an unrecorded walk will not appear. Start by comparing a known workout's date and duration with its source before using record counts to assess consistency.

For weekly charts, date boundaries and absent records require another explicit decision. The Python walkthrough shows a reproducible way to make that decision and report coverage.

Separate upload freshness from measurement freshness

A dashboard that quietly stops receiving data can still look convincing. The receipt-age panel makes one operational fact visible: how many hours have elapsed since the server received the latest batch for the chosen user.

It uses a rolling 90-day lookback and deliberately ignores the dashboard time picker. If you inspect last month's workouts, you still want to know whether uploads are arriving now. If there is no batch in that lookback, the panel displays “No data.”

A recent receipt does not prove that every HealthKit type is current. A phone can upload historical records during a backfill; a batch may contain one type while another remains unavailable. Compare the newest actual measurement for the metric you care about when investigating freshness. The upload stat is a starting point, not a “sync complete” badge.

Check one known day before expanding

Open Query Inspector on each panel. Confirm that the expanded SQL contains your intended user and time bounds. The template uses ${user:sqlstring} for quoting and a UUID cast for type checking; see Grafana's variable documentation for how substitution works.

Choose one completed day and compare its step value, provenance, and workout records with the underlying data. Then test a range with no records. An empty chart should remain empty; avoid filling every missing day with zero to make a continuous-looking series.

Here are the checked results for the current download, using synthetic fixtures on PostgreSQL 17 on October 25. Each query ran as the read-only Grafana role; the SQL embedded in the JSON matched the separate templates.

CheckResult in the synthetic fixtureWhat to check in your own dashboard
Daily steps, September 1–1414 rowsThe expected dates and values, with no invented zero days
Workout points6 rowsOne point for each recorded session starting in the range
Provenance table14 rowsA calculation source beside each daily value
Receipt ageOne row with a valueRecent receipt separately from recent measurements
User and date filteringOther-user and out-of-range sentinels excludedThe intended UUID and bounds in expanded SQL
Los Angeles calendarSeptember 2 at 00:30 UTC maps to September 1; September 1 local midnight plots at 07:00 UTCThe account calendar and dashboard display zone agree

These checks validate query behavior against the fixture, not production TimescaleDB performance or a new Grafana rendering. The download README records the scope. After importing, open Inspect → Query, refresh, and compare the expanded SQL and returned rows with one day you know.

Once the dashboard agrees with known records, add panels one question at a time. Keep units in the axis label, provenance beside summaries, and time bounds on every large query. Leave missing values visible.

apple-healthgrafanaself-hostingdata-analysis

Keep reading

The rest of the blog, or the reference pages for every health data type.