<@U04S8PLJWMT> i want to show the sync stats per s...
# ask-ai
h
@kapa.ai i want to show the sync stats per stream of a connection. Now airbyte shows stream sync stats for all the sync that happened or the latest synced that happend
k
Airbyte now provides per-stream sync stats for connections, and you can view these stats for recent syncs, not just the latest one. Specifically, on the Connection Status page in Airbyte Cloud and Self-Managed Enterprise, you can see the status and record counts for each stream for the last 8 syncs. This allows you to monitor the incremental progress and troubleshoot by identifying which streams are erroring or have issues over multiple syncs, not just the most recent one. You can hover over the graph to select and review the sync history for each stream individually, including record counts and sync duration per stream for each sync event [Connection status](https://docs.airbyte.com/platform/cloud/managing-airbyte-cloud/review-connection-status#review-one-streams-status) [June 2024 Release Notes](https://docs.airbyte.com/release_notes/june_2024). So, Airbyte shows stream sync stats for the last several syncs (up to 8), not only the latest sync.
h
@kapa.ai i want to do it for self hosted airbyte, how can i do it ? which api to use and like we have a history of syncs can we also see the streams info for all the syncs?
k
A message from kapa.ai
For self-hosted Airbyte, you can retrieve the sync history and per-stream sync stats using the Airbyte API. Specifically, you should use the /v1/jobs/list API endpoint to fetch all jobs (syncs) for a specific connection. The configId parameter in this API is your connectionId. This will give you a list of sync jobs for the connection [Is it possible to fetch the sync history through Airbyte API?](https://discuss.airbyte.io/t/2235). Each job object returned by this API contains detailed information about the sync, including per-stream statistics such as records emitted, bytes emitted, and records committed for each stream. This allows you to programmatically access the stream-level sync stats for all historical syncs, not just the latest one. Example API request:
Copy code
json POST /v1/jobs/list {   "configTypes": ["sync"],   "configId": "<your-connection-id>",   "pagination": {     "pageSize": 20,     "rowOffset": 0   } }
The response will include a list of jobs, and each job will have a streamStats section with per-stream sync stats for that particular sync. So, yes, you can see the streams info for all the syncs by using the jobs/list API and inspecting the streamStats in each job object [Is it possible to fetch the sync history through Airbyte API?](https://discuss.airbyte.io/t/2235) [Source Postgres - Sync completes without failure but not all streams get synced](https://discuss.airbyte.io/t/2049).
h
@kapa.ai how can i get the list of all streams in a sync with their status and duration of sync (time) .
k
A message from kapa.ai
To get the list of all streams in a sync, along with their status and duration, you can use the Airbyte API to fetch the sync (job) history for a connection. Here’s how you can approach this for self-hosted Airbyte: 1. Fetch Sync History: Use the
/v1/jobs/list
API endpoint with the
configId
set to your connection ID and
configTypes
set to
sync
. This will return a list of sync jobs for the connection. Example request:
Copy code
json    POST /v1/jobs/list    {      "configTypes": ["sync"],      "configId": "<your-connection-id>",      "pagination": {        "pageSize": 20,        "rowOffset": 0      }    }
The response includes job objects for each sync, each containing a
streamStats
section with per-stream statistics such as records emitted, bytes emitted, and records committed for each stream. This allows you to see which streams were part of the sync and their respective stats [Is it possible to fetch the sync history through Airbyte API?](https://discuss.airbyte.io/t/2235) [Source Postgres - Sync completes without failure but not all streams get synced](https://discuss.airbyte.io/t/2049). 2. Stream Status: The
streamStats
in each job object provides information about each stream, such as: -
recordsEmitted
-
recordsCommitted
-
bytesEmitted
- (and sometimes) error or status indicators However, the explicit "status" (e.g., synced, error, action required) per stream is primarily available in the Airbyte UI, but the API provides enough detail to infer if a stream was successfully synced (e.g., by checking if
recordsCommitted
> 0). 3. Duration of Sync per Stream: The knowledge sources do not explicitly mention that the API provides the duration of sync per stream. The overall sync duration is available at the job level, but per-stream timing is not directly documented in the API responses. The UI does show per-stream sync duration, but this may not be exposed via the public API in self-hosted Airbyte as of the latest documentation [Connection status](https://docs.airbyte.com/platform/cloud/managing-airbyte-cloud/review-connection-status). Summary: - Use
/v1/jobs/list
to get all syncs for a connection. - Inspect the
streamStats
in each job for per-stream information. - Status can be inferred from stats, but explicit per-stream status and duration may not be fully available via the API in self-hosted Airbyte. If you need exact per-stream sync duration and status as shown in the UI, this may not be fully supported via the public API for self-hosted Airbyte at this time. The knowledge sources do not provide enough information to confirm this feature is available outside of the UI.
h
@kapa.ai if there are 10 streams, and 2 streams fialed syncing, rest synced sucessfully, then in the syncstats do we see
recordsCommitted
== 0 or not
k
A message from kapa.ai
If a stream fails to sync, the
recordsCommitted
value for that stream in the
streamStats
will be
0
. This is evident from multiple sync summaries in the knowledge sources, where failed or cancelled syncs show
recordsCommitted: 0
for the affected streams, while successfully synced streams have a positive
recordsCommitted
value. For example, in a failed sync, you can see:
Copy code
json "streamStats": [   {     "streamName": "graph_meta_datas",     "stats": {       "recordsEmitted": 10,       "bytesEmitted": 8286,       "recordsCommitted": null     }   },   ... ]
Or:
Copy code
json "streamStats": [   {     "streamName": "smart_solve",     "stats": {       "recordsEmitted": 10,       "bytesEmitted": 123718,       "recordsCommitted": 0     }   } ]
This means that for streams that failed to sync,
recordsCommitted
will be
0
(or sometimes
null
), while for streams that synced successfully,
recordsCommitted
will reflect the number of records actually committed [Forum Post: Mongodb to s3 connection failing with same errors](https://discuss.airbyte.io/t/774) [Github Issue: [source-mongodb] Records get extracted and loaded but it only shows extracted and 0 loaded](https://github.com/airbytehq/airbyte/issues/45133).
h
@kapa.ai but if there is an incemental sync, then also it will show zero right ? then this is clearly an anomaly
k
A message from kapa.ai
New message text here
h
@kapa.ai Error: Failed to check the source connection: Field 'reader_options' is not valid JSON object. https://www.json.org/ while uploading an excel sheet
k
A message from kapa.ai
The error message "Field 'reader_options' is not valid JSON object" indicates that the value you entered for the
reader_options
field is not properly formatted as a JSON object. The
reader_options
field must be a valid JSON string (e.g.,
{"option": "value"}
), not plain text or malformed JSON. How to fix: - Make sure you enter a valid JSON object in the
reader_options
field. For example:
Copy code
json   {"sheet_name": "Sheet1"}
- If you do not need any special options, you can leave the
reader_options
field blank. Refer to the [Airbyte documentation on Reader Options](https://docs.airbyte.com/integrations/sources/file#reader-options) for more details and examples. Double-check your input using a JSON validator like [json.org](https://www.json.org/) if you are unsure. If you continue to see this error, ensure that you are not entering a plain string or malformed JSON (e.g., missing braces, using single quotes instead of double quotes, etc.) in the
reader_options
field [Reader Options](https://docs.airbyte.com/integrations/sources/file#reader-options).
h
@kapa.ai what should i send a sempty reader_options ? 1. right now a "" string is going, which is causing the error ? what should go if i don't want to send reader option
k
A message from kapa.ai
If you do not want to send any
reader_options
, you should leave the field blank (i.e., do not provide any value at all), rather than sending an empty string (
""
). The documentation states that the
reader_options
field is optional and "may be left blank if you do not wish to configure custom Reader options" [Step 3: Complete the connector setup](https://docs.airbyte.com/integrations/sources/file#step-3-complete-the-connector-setup). So, **do not send
""
(an empty string)**—just omit the field or leave it empty in the UI or API request. This will prevent the JSON validation error.
h
@kapa.ai by empty you mean ?
k
A message from kapa.ai
By "empty," I mean you should not provide any value at all for the
reader_options
field—just leave it blank. In the Airbyte UI, this means leaving the field empty. In an API request, you can either omit the
reader_options
field entirely or set it to
null
, but you should not send an empty string (
""
), as that will cause a validation error. The documentation says: > "This field may be left blank if you do not wish to configure custom Reader options." [Step 3: Complete the connector setup](https://docs.airbyte.com/integrations/sources/file#step-3-complete-the-connector-setup) So, "empty" means: - In the UI: leave the field blank. - In JSON/API: either omit the field or set it to
null
, but do not use
""
.