diff --git a/services/observability/grafana/provisioning/dashboards/json/tagbase-ingest.json b/services/observability/grafana/provisioning/dashboards/json/tagbase-ingest.json index 55fb6dbf..c0973b49 100644 --- a/services/observability/grafana/provisioning/dashboards/json/tagbase-ingest.json +++ b/services/observability/grafana/provisioning/dashboards/json/tagbase-ingest.json @@ -1,107 +1,909 @@ { - "annotations": { "list": [] }, - "editable": true, - "fiscalYearStartMonth": 0, - "graphTooltip": 1, - "id": null, - "links": [], - "panels": [ + "annotations": [ { - "datasource": { "type": "prometheus", "uid": "prometheus" }, - "fieldConfig": { "defaults": { "unit": "reqps" }, "overrides": [] }, - "gridPos": { "h": 8, "w": 8, "x": 0, "y": 0 }, - "id": 1, - "title": "Ingest request rate", - "type": "timeseries", - "targets": [ - { - "expr": "sum by (outcome) (rate(tagbase_ingest_requests_total[5m]))", - "legendFormat": "{{outcome}}", - "refId": "A" + "kind": "AnnotationQuery", + "spec": { + "builtIn": true, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "query": { + "datasource": { + "name": "-- Grafana --" + }, + "group": "grafana", + "kind": "DataQuery", + "spec": {}, + "version": "v0" } - ] + } + } + ], + "cursorSync": "Crosshair", + "description": "copy", + "editable": true, + "elements": { + "panel-1": { + "kind": "Panel", + "spec": { + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "hidden": false, + "query": { + "datasource": { + "name": "prometheus" + }, + "group": "prometheus", + "kind": "DataQuery", + "spec": { + "expr": "sum by (outcome) (rate(tagbase_ingest_requests_total[5m]))", + "legendFormat": "{{outcome}}" + }, + "version": "v0" + }, + "refId": "A" + } + } + ], + "queryOptions": {}, + "transformations": [] + } + }, + "description": "", + "id": 1, + "links": [], + "title": "Ingest request rate", + "vizConfig": { + "group": "timeseries", + "kind": "VizConfig", + "spec": { + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "showValues": false, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "options": { + "annotations": { + "clustering": -1, + "multiLane": false + }, + "legend": { + "calcs": [], + "displayMode": "list", + "enableFacetedFilter": false, + "overflow": "ellipsis", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + } + }, + "version": "13.1.0" + } + } }, - { - "datasource": { "type": "prometheus", "uid": "prometheus" }, - "fieldConfig": { "defaults": { "unit": "s" }, "overrides": [] }, - "gridPos": { "h": 8, "w": 8, "x": 8, "y": 0 }, - "id": 2, - "title": "Ingest duration (p95)", - "type": "timeseries", - "targets": [ - { - "expr": "histogram_quantile(0.95, sum by (le, outcome) (rate(tagbase_ingest_duration_seconds_bucket[5m])))", - "legendFormat": "{{outcome}}", - "refId": "A" + "panel-2": { + "kind": "Panel", + "spec": { + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "hidden": false, + "query": { + "datasource": { + "name": "prometheus" + }, + "group": "prometheus", + "kind": "DataQuery", + "spec": { + "expr": "histogram_quantile(0.95, sum by (le, outcome) (rate(tagbase_ingest_duration_seconds_bucket[5m])))", + "legendFormat": "{{outcome}}" + }, + "version": "v0" + }, + "refId": "A" + } + } + ], + "queryOptions": {}, + "transformations": [] + } + }, + "description": "", + "id": 2, + "links": [], + "title": "Ingest duration (p95)", + "vizConfig": { + "group": "timeseries", + "kind": "VizConfig", + "spec": { + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "showValues": false, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "options": { + "annotations": { + "clustering": -1, + "multiLane": false + }, + "legend": { + "calcs": [], + "displayMode": "list", + "enableFacetedFilter": false, + "overflow": "ellipsis", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + } + }, + "version": "13.1.0" } - ] + } }, - { - "datasource": { "type": "prometheus", "uid": "prometheus" }, - "fieldConfig": { "defaults": { "unit": "ops" }, "overrides": [] }, - "gridPos": { "h": 8, "w": 8, "x": 16, "y": 0 }, - "id": 3, - "title": "Rows written / DB errors", - "type": "timeseries", - "targets": [ - { - "expr": "sum(rate(tagbase_ingest_rows_written_total[5m]))", - "legendFormat": "rows_written", - "refId": "A" + "panel-3": { + "kind": "Panel", + "spec": { + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "hidden": false, + "query": { + "datasource": { + "name": "prometheus" + }, + "group": "prometheus", + "kind": "DataQuery", + "spec": { + "expr": "sum(rate(tagbase_ingest_rows_written_total[5m]))", + "legendFormat": "rows_written" + }, + "version": "v0" + }, + "refId": "A" + } + }, + { + "kind": "PanelQuery", + "spec": { + "hidden": false, + "query": { + "datasource": { + "name": "prometheus" + }, + "group": "prometheus", + "kind": "DataQuery", + "spec": { + "expr": "sum by (operation) (rate(tagbase_db_errors_total[5m]))", + "legendFormat": "db_error:{{operation}}" + }, + "version": "v0" + }, + "refId": "B" + } + } + ], + "queryOptions": {}, + "transformations": [] + } }, - { - "expr": "sum by (operation) (rate(tagbase_db_errors_total[5m]))", - "legendFormat": "db_error:{{operation}}", - "refId": "B" + "description": "", + "id": 3, + "links": [], + "title": "Rows written / DB errors", + "vizConfig": { + "group": "timeseries", + "kind": "VizConfig", + "spec": { + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "showValues": false, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": 0 + }, + { + "color": "yellow", + "value": 90 + }, + { + "color": "green", + "value": 99 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "options": { + "annotations": { + "clustering": -1, + "multiLane": false + }, + "legend": { + "calcs": [], + "displayMode": "list", + "enableFacetedFilter": false, + "overflow": "ellipsis", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + } + }, + "version": "13.1.0" } - ] + } }, - { - "datasource": { "type": "tempo", "uid": "tempo" }, - "gridPos": { "h": 8, "w": 12, "x": 0, "y": 8 }, - "id": 4, - "title": "Recent ingest traces", - "type": "table", - "options": { - "showHeader": true, - "cellHeight": "sm", - "footer": { - "show": false, - "countRows": false, - "reducer": ["sum"], - "fields": "" + "panel-4": { + "kind": "Panel", + "spec": { + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "hidden": false, + "query": { + "datasource": { + "name": "tempo" + }, + "group": "tempo", + "kind": "DataQuery", + "spec": { + "limit": 20, + "query": "{ resource.service.name=\"tagbase_server\" && name=~\"ingest.*\" }", + "queryType": "traceql", + "tableType": "traces" + }, + "version": "v0" + }, + "refId": "A" + } + } + ], + "queryOptions": {}, + "transformations": [] + } + }, + "description": "", + "id": 4, + "links": [], + "title": "Recent ingest traces", + "vizConfig": { + "group": "table", + "kind": "VizConfig", + "spec": { + "fieldConfig": { + "defaults": { + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "footer": { + "reducers": [] + }, + "inspect": false + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "options": { + "cellHeight": "sm", + "showHeader": true + } + }, + "version": "13.1.0" } - }, - "targets": [ - { - "datasource": { "type": "tempo", "uid": "tempo" }, - "queryType": "traceql", - "query": "{ resource.service.name=\"tagbase_server\" && name=~\"ingest.*\" }", - "limit": 20, - "tableType": "traces", - "refId": "A" + } + }, + "panel-5": { + "kind": "Panel", + "spec": { + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "hidden": false, + "query": { + "datasource": { + "name": "loki" + }, + "group": "loki", + "kind": "DataQuery", + "spec": { + "expr": "{service_name=~\"tagbase_server|nginx|postgis|fswatch\"}" + }, + "version": "v0" + }, + "refId": "A" + } + } + ], + "queryOptions": {}, + "transformations": [] + } + }, + "description": "", + "id": 5, + "links": [], + "title": "Service logs", + "vizConfig": { + "group": "logs", + "kind": "VizConfig", + "spec": { + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "options": { + "dedupStrategy": "none", + "enableInfiniteScrolling": false, + "enableLogDetails": true, + "prettifyLogMessage": true, + "showControls": false, + "showFieldSelector": false, + "showLevel": true, + "showTime": false, + "sortOrder": "Descending", + "timestampResolution": "ms", + "unwrappedColumns": false, + "wrapLogMessage": false + } + }, + "version": "13.1.0" } - ] + } }, - { - "datasource": { "type": "loki", "uid": "loki" }, - "gridPos": { "h": 8, "w": 12, "x": 12, "y": 8 }, - "id": 5, - "title": "Service logs", - "type": "logs", - "targets": [ + "panel-6": { + "kind": "Panel", + "spec": { + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "hidden": false, + "query": { + "datasource": { + "name": "prometheus" + }, + "group": "prometheus", + "kind": "DataQuery", + "spec": { + "editorMode": "code", + "expr": "sum(increase(tagbase_ingest_requests_total{outcome=\"success\"}[24h]))\n/\nsum(increase(tagbase_ingest_requests_total[24h]))\n* 100", + "legendFormat": "{{outcome}}", + "range": true + }, + "version": "v0" + }, + "refId": "A" + } + } + ], + "queryOptions": {}, + "transformations": [] + } + }, + "description": "", + "id": 6, + "links": [], + "title": "File ingestion success rate", + "vizConfig": { + "group": "gauge", + "kind": "VizConfig", + "spec": { + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "options": { + "barShape": "flat", + "barWidthFactor": 0.3, + "effects": { + "barGlow": false, + "centerGlow": false, + "gradient": true + }, + "endpointMarker": "point", + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "segmentCount": 1, + "segmentSpacing": 0.3, + "shape": "gauge", + "showThresholdLabels": false, + "showThresholdMarkers": false, + "sizing": "auto", + "sparkline": true, + "textMode": "auto" + } + }, + "version": "13.1.0" + } + } + }, + "panel-7": { + "kind": "Panel", + "spec": { + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "hidden": false, + "query": { + "datasource": { + "name": "prometheus" + }, + "group": "prometheus", + "kind": "DataQuery", + "spec": { + "editorMode": "code", + "expr": "sum by (outcome) (tagbase_ingest_requests_total)", + "legendFormat": "{{outcome}}", + "range": true + }, + "version": "v0" + }, + "refId": "A" + } + } + ], + "queryOptions": {}, + "transformations": [] + } + }, + "description": "", + "id": 7, + "links": [], + "title": "File ingestion", + "vizConfig": { + "group": "timeseries", + "kind": "VizConfig", + "spec": { + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "showValues": false, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "options": { + "annotations": { + "clustering": -1, + "multiLane": false + }, + "legend": { + "calcs": [], + "displayMode": "list", + "enableFacetedFilter": false, + "overflow": "ellipsis", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + } + }, + "version": "13.1.0" + } + } + } + }, + "layout": { + "kind": "RowsLayout", + "spec": { + "rows": [ { - "expr": "{service_name=~\"tagbase_server|nginx|postgis|fswatch\"}", - "refId": "A" + "kind": "RowsLayoutRow", + "spec": { + "collapse": false, + "layout": { + "kind": "GridLayout", + "spec": { + "items": [ + { + "kind": "GridLayoutItem", + "spec": { + "element": { + "kind": "ElementReference", + "name": "panel-1" + }, + "height": 8, + "width": 8, + "x": 0, + "y": 0 + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "element": { + "kind": "ElementReference", + "name": "panel-2" + }, + "height": 8, + "width": 8, + "x": 8, + "y": 0 + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "element": { + "kind": "ElementReference", + "name": "panel-3" + }, + "height": 8, + "width": 8, + "x": 16, + "y": 0 + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "element": { + "kind": "ElementReference", + "name": "panel-7" + }, + "height": 8, + "width": 8, + "x": 0, + "y": 8 + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "element": { + "kind": "ElementReference", + "name": "panel-6" + }, + "height": 8, + "width": 8, + "x": 8, + "y": 8 + } + } + ] + } + }, + "title": "Server metrics" + } + }, + { + "kind": "RowsLayoutRow", + "spec": { + "collapse": false, + "layout": { + "kind": "AutoGridLayout", + "spec": { + "columnWidthMode": "standard", + "items": [ + { + "kind": "AutoGridLayoutItem", + "spec": { + "element": { + "kind": "ElementReference", + "name": "panel-5" + } + } + }, + { + "kind": "AutoGridLayoutItem", + "spec": { + "element": { + "kind": "ElementReference", + "name": "panel-4" + } + } + } + ], + "maxColumnCount": 3, + "rowHeightMode": "standard" + } + }, + "title": "Server logs" + } } ] } - ], - "schemaVersion": 39, - "tags": ["tagbase", "ingest", "otel"], - "templating": { "list": [] }, - "time": { "from": "now-1h", "to": "now" }, + }, + "links": [], + "liveNow": false, + "preload": false, + "tags": [], + "timeSettings": { + "autoRefresh": "", + "autoRefreshIntervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "fiscalYearStartMonth": 0, + "from": "2026-07-30T01:39:04.641Z", + "hideTimepicker": false, + "timezone": "browser", + "to": "2026-08-02T13:37:27.125Z" + }, "title": "Tagbase Ingest", - "uid": "tagbase-ingest", - "version": 1 + "variables": [] } diff --git a/tagbase_server/tagbase_server/utils/processing_utils.py b/tagbase_server/tagbase_server/utils/processing_utils.py index def7aa23..8c880fff 100644 --- a/tagbase_server/tagbase_server/utils/processing_utils.py +++ b/tagbase_server/tagbase_server/utils/processing_utils.py @@ -11,6 +11,7 @@ from tagbase_server.telemetry import ( get_tracer, record_db_error, + record_ingest_request, record_rows_written, ) from tagbase_server.utils.db_utils import connect @@ -545,27 +546,33 @@ def process_etuff_file(file, version=None, notes=None): conn = connect() if not hasattr(conn, "cursor"): record_db_error("connect") + record_ingest_request("error", round(time.perf_counter() - start, 2)) return 1 conn.autocommit = True with tracer.start_as_current_span("ingest.parse_etuff"): - ( - instrument_name, - serial_number, - ptt, - platform, - referencetrack_included, - file_content, - metadata_content, - number_global_attributes_lines, - ) = get_dataset_properties(submission_filename) - ( - content_hash, - metadata_hash, - entire_file_hash, - ) = _compute_submission_hashes( - submission_filename, file_content, metadata_content - ) + try: + ( + instrument_name, + serial_number, + ptt, + platform, + referencetrack_included, + file_content, + metadata_content, + number_global_attributes_lines, + ) = get_dataset_properties(submission_filename) + ( + content_hash, + metadata_hash, + entire_file_hash, + ) = _compute_submission_hashes( + submission_filename, file_content, metadata_content + ) + except Exception: + logger.exception("Error parsing etuff file: %s", submission_filename) + record_ingest_request("error", round(time.perf_counter() - start, 2)) + raise with conn: with conn.cursor() as cur: @@ -577,6 +584,9 @@ def process_etuff_file(file, version=None, notes=None): submission_filename, entire_file_hash, ) + record_ingest_request( + "duplicate", round(time.perf_counter() - start, 2) + ) return 1 dataset_id = get_dataset_id( @@ -624,6 +634,9 @@ def process_etuff_file(file, version=None, notes=None): dataset_id, metadata_hash, ) + record_ingest_request( + "metadata_only", round(time.perf_counter() - start, 2) + ) return 1 proc_obs, len_proc_obs = _build_proc_observations( @@ -641,6 +654,9 @@ def process_etuff_file(file, version=None, notes=None): ) if sub_elapsed is False: record_db_error("migrate_proc_observations") + record_ingest_request( + "error", round(time.perf_counter() - start, 2) + ) return 1 record_rows_written(len_proc_obs) logger.info( @@ -650,6 +666,9 @@ def process_etuff_file(file, version=None, notes=None): ) except Exception: record_db_error("persist") + record_ingest_request( + "error", round(time.perf_counter() - start, 2) + ) raise conn.commit() @@ -659,6 +678,7 @@ def process_etuff_file(file, version=None, notes=None): finish = time.perf_counter() elapsed = round(finish - start, 2) + record_ingest_request("success", elapsed) logger.info( "Data file %s successfully ingested into Tagbase DB. Total time: %s second(s)", submission_filename,