@trackunit/iris-app 1.12.9 → 1.12.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +1 -1
  3. package/src/executors/submit/executor.js.map +1 -0
  4. package/src/executors/unpublish/executor.js.map +1 -0
  5. package/src/executors/utils/authentication.js.map +1 -0
  6. package/src/executors/utils/irisAppServerSettings.js.map +1 -0
  7. package/src/executors/utils/src/index.js.map +1 -0
  8. package/src/generators/ai-agent-sync/README.md +5 -2
  9. package/src/generators/ai-agent-sync/generator.d.ts +1 -1
  10. package/src/generators/ai-agent-sync/generator.js +29 -4
  11. package/src/generators/ai-agent-sync/generator.js.map +1 -0
  12. package/src/generators/create/generator.js.map +1 -0
  13. package/src/generators/extend/dependencies.js.map +1 -0
  14. package/src/generators/extend/generator.js.map +1 -0
  15. package/src/generators/preset/files/.agents/skills/browser-testing/SKILL.md +193 -0
  16. package/src/generators/preset/files/.agents/skills/create-app/SKILL.md +191 -0
  17. package/src/generators/preset/files/.agents/skills/customfields/SKILL.md +239 -0
  18. package/src/generators/preset/files/.agents/skills/graphql/SKILL.md +147 -0
  19. package/src/generators/preset/files/.agents/skills/graphql-timeseries/SKILL.md +193 -0
  20. package/src/generators/preset/files/.agents/skills/irisx-app-sdk/SKILL.md +116 -0
  21. package/src/generators/preset/files/.agents/skills/react-core-hooks/SKILL.md +215 -0
  22. package/src/generators/preset/files/.agents/skills/tables-and-sorting/SKILL.md +122 -0
  23. package/src/generators/preset/files/.agents/skills/widget-extensions/SKILL.md +245 -0
  24. package/src/generators/preset/files/.cursor/mcp.json +4 -0
  25. package/src/generators/preset/generator.js.map +1 -0
  26. package/src/generators/preset/root-files/AGENTS.md +43 -0
  27. package/src/generators/preset/root-files/CLAUDE.md +17 -0
  28. package/src/index.js.map +1 -0
  29. package/src/utils/ast/astUtils.js.map +1 -0
  30. package/src/utils/fileUpdater.js.map +1 -0
  31. package/src/generators/preset/files/.cursor/commands/create-app.md +0 -226
  32. package/src/generators/preset/files/.cursor/rules/browser-irisx-development.mdc +0 -246
  33. package/src/generators/preset/files/.cursor/rules/graphql-timeseries.md +0 -260
  34. package/src/generators/preset/files/.cursor/rules/irisx-app-sdk-customfields.md +0 -305
  35. package/src/generators/preset/files/.cursor/rules/irisx-app-sdk-graphql.md +0 -30
  36. package/src/generators/preset/files/.cursor/rules/irisx-app-sdk.mdc +0 -82
  37. package/src/generators/preset/files/.cursor/rules/react-core-hooks.md +0 -155
  38. package/src/generators/preset/files/.cursor/rules/rules-index.mdc +0 -10
  39. package/src/generators/preset/files/.cursor/rules/structured-development.mdc +0 -86
  40. package/src/generators/preset/files/.cursor/rules/tables-and-sorting.mdc +0 -126
  41. package/src/generators/preset/files/.cursor/rules/widget-extensions.md +0 -323
@@ -1,246 +0,0 @@
1
- # Browser Usage for IrisX App Development
2
-
3
- ## Overview
4
- This rule defines the browser-first workflow for developing and testing IrisX Apps in Trackunit Manager.
5
-
6
- **⚠️ CRITICAL: IrisX Apps are ALWAYS tested at https://new.manager.trackunit.com/goto/iris-app-dev - NEVER on localhost!**
7
-
8
- When the dev server runs locally (via `npx nx run [app-name]:serve`), it serves the app files, but you MUST test the app in the Trackunit Manager environment at the URL above. This is because IrisX apps are extensions that integrate into Trackunit Manager and require the host platform to function.
9
-
10
- ## Initial Browser Setup
11
-
12
- ### 1. Open Browser and Wait for Login
13
- When starting IrisX App development:
14
-
15
- ```
16
- 1. Navigate to: https://new.manager.trackunit.com/goto/iris-app-dev
17
- (This is THE ONLY URL to test IrisX apps - NEVER use localhost!)
18
- 2. Inform user: "I've opened Trackunit Manager at https://new.manager.trackunit.com/goto/iris-app-dev. Please log in."
19
- 3. Wait for user to complete login (be patient - may take 2-4 minutes)
20
- 4. Do NOT proceed until you see the Trackunit Manager interface loaded
21
- ```
22
-
23
- ### 2. Verify Local Dev Mode is Enabled
24
- After user is logged in, check if local dev mode is active:
25
-
26
- ```
27
- a) Take browser snapshot
28
- b) Look for element with data-testid="local-mode-tooltip-parent" in the sidebar
29
- c) If "Use Local Apps" toggle is visible and enabled → local dev mode is ON
30
- d) If NOT found or NOT enabled → proceed to step 3
31
- ```
32
-
33
- ### 3. Enable Local Dev Mode (if needed)
34
- If local dev mode is not enabled:
35
-
36
- ```
37
- a) Navigate to: https://new.manager.trackunit.com/goto/iris-app-dev
38
- b) Wait for page to load
39
- c) Take snapshot to verify the local dev mode page loaded
40
- d) Look for "Use Local Apps" toggle in sidebar (data-testid="local-mode-tooltip-parent")
41
- e) If toggle is OFF, click it to enable local dev mode
42
- f) Wait 2 seconds for activation
43
- g) Verify toggle is now ON
44
- ```
45
-
46
- ### 4. Navigate to Extension
47
- Based on extension type, navigate to where the extension should appear:
48
-
49
- **FLEET_EXTENSION:**
50
- - Main menu → Look for your app name in the menu items
51
- - Click to open the extension
52
-
53
- **ASSET_HOME_EXTENSION:**
54
- - Navigate to Assets → Open any asset
55
- - Look for new tab with your extension name
56
- - Click the tab
57
-
58
- **SITE_HOME_EXTENSION:**
59
- - Navigate to Sites → Open any site
60
- - Look for new tab with your extension name
61
- - Click the tab
62
-
63
- **WIDGET_EXTENSION:**
64
- - Navigate to Dashboard
65
- - Click "Add Widget" or similar
66
- - Look for your widget in the list
67
-
68
- ## Testing After Code Changes
69
-
70
- ### Reload Strategy
71
- After making code changes to your extension:
72
-
73
- **1. Check Lints First (Zero Tolerance):**
74
- ```
75
- - Run read_lints on modified files
76
- - Fix ALL errors before testing in browser
77
- - Do not proceed with any TypeScript or linter errors
78
- ```
79
-
80
- **2. Reload Browser:**
81
- The dev server hot-reloads, but sometimes a full page refresh is needed:
82
-
83
- ```
84
- Option A - Wait for Hot Reload:
85
- - Wait 2-3 seconds after saving files
86
- - Check if changes appear automatically
87
- - If extension goes blank or changes don't appear → proceed to Option B
88
-
89
- Option B - Manual Refresh:
90
- For macOS:
91
- - Press Command+R to reload page
92
- OR
93
- - Use browser_snapshot, then browser_evaluate with: location.reload()
94
-
95
- For Windows:
96
- - Press Ctrl+R to reload page (use browser_press_key)
97
- OR
98
- - Use browser_evaluate with: location.reload()
99
-
100
- Option C - Hard Refresh (if normal refresh doesn't work):
101
- For macOS:
102
- - Press Command+Shift+R for hard reload
103
- OR
104
- - Use browser_evaluate with: location.reload(true)
105
-
106
- For Windows:
107
- - Press Ctrl+Shift+R for hard reload
108
- OR
109
- - Use browser_evaluate with: location.reload(true)
110
- ```
111
-
112
- **⚠️ IMPORTANT - Manifest Changes Require Re-Serve:**
113
- ```
114
- If you modified iris-app-manifest.ts (scopes, CSP headers, metadata, etc.):
115
- - Browser reload is NOT enough
116
- - You MUST stop the dev server (Ctrl+C)
117
- - Re-run: npx nx run [app-name]:serve
118
- - Wait for server to restart
119
- - Then reload browser
120
-
121
- Manifest changes include:
122
- - Adding/removing scopes
123
- - Updating CSP headers (cspHeader)
124
- - Changing app metadata
125
- - Modifying extension configurations
126
- ```
127
-
128
- **3. Verify Extension Loaded:**
129
- ```
130
- - Take browser snapshot
131
- - Look for your extension content
132
- - Check if it's blank/empty → may need hard refresh
133
- - Verify expected UI elements are present
134
- ```
135
-
136
- **4. Check Console for Errors:**
137
- ```
138
- - Use browser_console_messages tool
139
- - Look for errors (red messages)
140
- - Common issues:
141
- - GraphQL errors (check scopes in manifest)
142
- - CSP violations (update cspHeader in manifest)
143
- - Module loading errors (check imports)
144
- - Runtime errors (check code logic)
145
- ```
146
-
147
- **5. Check Network Requests (if using GraphQL/APIs):**
148
- ```
149
- - Use browser_network_requests tool
150
- - Note: GraphQL returns 200 OK even with errors - inspect response bodies
151
- - Look for "errors" array in GraphQL responses
152
- - Check for HTTP status errors: 400 (bad syntax), 401/403 (auth/scopes), 500 (server error)
153
- - Common issues: missing scopes in manifest, incorrect query structure
154
- ```
155
-
156
- ## Troubleshooting Common Issues
157
-
158
- ### Extension Shows Blank After Changes
159
- ```
160
- 1. Try hard refresh (Command+Shift+R or Ctrl+Shift+R)
161
- 2. Check browser console for errors
162
- 3. Check if dev server is still running
163
- 4. Verify file saved correctly
164
- 5. Check for TypeScript compilation errors
165
- 6. Navigate away and back to extension
166
- ```
167
-
168
- ### "Use Local Apps" Toggle Not Found
169
- ```
170
- 1. Verify user is logged in successfully
171
- 2. Navigate directly to https://new.manager.trackunit.com/goto/iris-app-dev
172
- 3. Wait for page to fully load
173
- 4. Take snapshot to see what's visible
174
- 5. Look for "Use Local Apps" toggle in sidebar (data-testid="local-mode-tooltip-parent")
175
- 6. If found and OFF, click it to enable local dev mode
176
- 7. Wait 2 seconds for activation
177
- 8. Verify toggle is now ON
178
- 9. May need to scroll sidebar to find toggle if not immediately visible
179
- ```
180
-
181
- ### Extension Not Appearing in Menu/Tabs
182
- ```
183
- 1. Verify dev server is running
184
- 2. Check manifest.json has correct extension type
185
- 3. If you changed iris-app-manifest.ts → MUST re-serve the app (stop and restart dev server)
186
- 4. Hard refresh browser
187
- 5. Disable and re-enable "Use Local Apps"
188
- 6. Check browser console for loading errors
189
- 7. Verify extension-manifest.ts is configured correctly
190
- ```
191
-
192
- ### GraphQL/API Errors
193
- ```
194
- 1. Use browser_network_requests to find GraphQL requests
195
- 2. Inspect response body for "errors" array (GraphQL returns 200 even with errors)
196
- 3. Common fixes:
197
- - Missing scopes → Add to iris-app-manifest.ts scopes array
198
- - CSP violations → Add domain to cspHeader in iris-app-manifest.ts
199
- - Query errors → Use Trackunit MCP validate-query to test
200
- - Auth issues → Deploy app to enable new scopes (inform user - never auto-deploy)
201
- 4. If manifest was changed → restart dev server
202
- ```
203
-
204
- ## Workflow Integration
205
-
206
- ### After Every Code Change:
207
- 1. ✅ Check lints (zero tolerance)
208
- 2. ✅ Fix all errors
209
- 3. ✅ Wait 2-3 seconds for hot reload
210
- 4. ✅ Refresh browser if needed
211
- 5. ✅ Take snapshot
212
- 6. ✅ Verify changes visible
213
- 7. ✅ Check console for errors
214
- 8. ✅ Check network tab if using APIs
215
- 9. ✅ Fix any issues before proceeding
216
-
217
- ### Before Moving to Next Feature:
218
- 1. ✅ Current feature fully working in browser
219
- 2. ✅ Zero linter/TypeScript errors
220
- 3. ✅ Zero browser console errors
221
- 4. ✅ All network requests successful
222
- 5. ✅ Screenshot of working feature
223
- 6. ✅ Documentation updated
224
-
225
- ## Best Practices
226
-
227
- 1. **Always Use https://new.manager.trackunit.com/goto/iris-app-dev:** Never test on localhost - IrisX apps require the Trackunit Manager host environment
228
- 2. **Keep Browser Open:** Always keep browser tab visible during development
229
- 3. **Snapshot Often:** Take snapshots after every change to verify UI
230
- 4. **Console is Your Friend:** Check console after every reload
231
- 5. **Network Tab for APIs:** Monitor all GraphQL/API requests
232
- 6. **Refresh Strategy:** Try soft refresh first, hard refresh if needed
233
- 7. **Patient with Login:** Give user adequate time to log in (2-4 minutes)
234
- 8. **Verify Before Proceeding:** Always confirm extension loads before writing features
235
- 9. **One Feature at a Time:** Test each feature completely before moving on
236
-
237
- ## Critical Reminders
238
-
239
- - **ALWAYS test at https://new.manager.trackunit.com/goto/iris-app-dev** - NEVER on localhost!
240
- - **Never proceed without browser verification** after initial setup
241
- - **Always check lints before browser testing** (zero tolerance for errors)
242
- - **Reload browser after every code change** to see updates
243
- - **Check console and network tab** for errors after each reload
244
- - **Fix issues immediately** before moving to next feature
245
- - **Take screenshots** to document working features
246
- - **Be patient with user login** - don't rush the authentication process
@@ -1,260 +0,0 @@
1
- # GraphQL Time Series API Usage
2
-
3
- This rule covers how to query time series data through GraphQL in IrisX App SDK using PromQL (Prometheus Query Language).
4
-
5
- ## Query Structure
6
-
7
- ### Range Query (time series data)
8
- ```graphql
9
- query GetTimeSeriesData($assetId: ID!, $start: DateTime!, $end: DateTime!, $step: Duration!) {
10
- asset(id: $assetId) {
11
- timeSeries {
12
- rangeQuery(query: "metric_name", start: $start, end: $end, step: $step) {
13
- data {
14
- ... on TimeSeriesMatrixData {
15
- result {
16
- values { timestamp value }
17
- }
18
- }
19
- }
20
- }
21
- }
22
- }
23
- }
24
- ```
25
-
26
- ### Instant Query (single point in time)
27
- ```graphql
28
- query GetInstantData($assetId: ID!, $time: DateTime!) {
29
- asset(id: $assetId) {
30
- timeSeries {
31
- instantQuery(query: "metric_name", time: $time) {
32
- data {
33
- ... on TimeSeriesVectorData {
34
- result { value { timestamp value } }
35
- }
36
- }
37
- }
38
- }
39
- }
40
- }
41
- ```
42
-
43
- ## Common Metrics
44
-
45
- ### Machine Insights (Possible Insights, not all assets will have all Insights)
46
- - `machine_insight_ac_average_frequency`
47
- - `machine_insight_ac_average_phase_to_neutral_rms_voltage`
48
- - `machine_insight_ac_average_phase_to_phase_rms_voltage`
49
- - `machine_insight_ac_average_rms_current`
50
- - `machine_insight_accelerometer_x_axis`
51
- - `machine_insight_accelerometer_y_axis`
52
- - `machine_insight_accelerometer_z_axis`
53
- - `machine_insight_ac_phase_l1_active_power`
54
- - `machine_insight_ac_phase_l1_frequency`
55
- - `machine_insight_ac_phase_l1_l2_rms_voltage`
56
- - `machine_insight_ac_phase_l1_netural_rms_voltage`
57
- - `machine_insight_ac_phase_l1_neutral_rms_voltage`
58
- - `machine_insight_ac_phase_l1_rms_current`
59
- - `machine_insight_ac_phase_l2_active_power`
60
- - `machine_insight_ac_phase_l2_frequency`
61
- - `machine_insight_ac_phase_l2_l3_rms_voltage`
62
- - `machine_insight_ac_phase_l2_netural_rms_voltage`
63
- - `machine_insight_ac_phase_l2_neutral_rms_voltage`
64
- - `machine_insight_ac_phase_l2_rms_current`
65
- - `machine_insight_ac_phase_l3_active_power`
66
- - `machine_insight_ac_phase_l3_frequency`
67
- - `machine_insight_ac_phase_l3_l1_rms_voltage`
68
- - `machine_insight_ac_phase_l3_netural_rms_voltage`
69
- - `machine_insight_ac_phase_l3_neutral_rms_voltage`
70
- - `machine_insight_ac_phase_l3_rms_current`
71
- - `machine_insight_ac_total_active_power`
72
- - `machine_insight_ac_total_apparent_power`
73
- - `machine_insight_ac_total_power_factor`
74
- - `machine_insight_ac_total_reactive_power`
75
- - `machine_insight_ac_total_relative_active_power_load_percentage`
76
- - `machine_insight_ac_total_relative_apparent_power_load_percentage`
77
- - `machine_insight_ac_total_relative_load_percentage`
78
- - `machine_insight_actual_engine_percent_torque`
79
- - `machine_insight_after_treatment_diesel_exhaust_fluid_concentration`
80
- - `machine_insight_after_treatment_diesel_exhaust_fluid_tank_level`
81
- - `machine_insight_after_treatment_diesel_exhaust_fluid_tank_temperature`
82
- - `machine_insight_after_treatment_diesel_particulate_filter_active_regeneration_state`
83
- - `machine_insight_after_treatment_diesel_particulate_filter_active_regeneration_status`
84
- - `machine_insight_after_treatment_diesel_particulate_filter_ash_load_percent`
85
- - `machine_insight_after_treatment_diesel_particulate_filter_differential_pressure`
86
- - `machine_insight_after_treatment_diesel_particulate_filter_intake_temperature`
87
- - `machine_insight_after_treatment_diesel_particulate_filter_passive_regeneration_status`
88
- - `machine_insight_after_treatment_diesel_particulate_filter_soot_load_percent`
89
- - `machine_insight_after_treatment_diesel_particulate_filter_state`
90
- - `machine_insight_after_treatment_diesel_particulate_filter_status`
91
- - `machine_insight_after_treatment_diesel_particulate_filter_time_since_last_active_regeneration`
92
- - `machine_insight_aftertreatment_diesel_particulate_filter_time_to_next_active_regeneration`
93
- - `machine_insight_after_treatment_exhaust_temperature`
94
- - `machine_insight_aftertreatment_scr_time_since_last_cleaning_event`
95
- - `machine_insight_altitude`
96
- - `machine_insight_ambient_air_temperature`
97
- - `machine_insight_average_load_factor_last_24`
98
- - `machine_insight_barometric_pressure`
99
- - `machine_insight_battery_charge_cycles_count`
100
- - `machine_insight_battery_charger_cumulative_input_energy`
101
- - `machine_insight_battery_charger_input_current`
102
- - `machine_insight_battery_charger_input_current_limit`
103
- - `machine_insight_battery_charger_input_voltage`
104
- - `machine_insight_battery_charger_output_current`
105
- - `machine_insight_battery_charger_output_current_limit`
106
- - `machine_insight_battery_charger_output_voltage`
107
- - `machine_insight_battery_charger_power_line_state`
108
- - `machine_insight_battery_charger_state`
109
- - `machine_insight_battery_cumulative_discharged_energy`
110
- - `machine_insight_battery_current`
111
- - `machine_insight_battery_potential`
112
- - `machine_insight_battery_remaining_charge_time`
113
- - `machine_insight_battery_remaining_run_time`
114
- - `machine_insight_battery_state_of_charge_percent`
115
- - `machine_insight_battery_state_of_health_percent`
116
- - `machine_insight_battery_temperature`
117
- - `machine_insight_cumulative_active_regeneration_hours`
118
- - `machine_insight_cumulative_co2_emissions`
119
- - `machine_insight_cumulative_engine_hours`
120
- - `machine_insight_cumulative_idle_hours`
121
- - `machine_insight_cumulative_idle_non_operating_hours`
122
- - `machine_insight_cumulative_load_count`
123
- - `machine_insight_cumulative_moving_hours`
124
- - `machine_insight_cumulative_operating_hours`
125
- - `machine_insight_cumulative_payload_totals`
126
- - `machine_insight_cumulative_productive_hours`
127
- - `machine_insight_diesel_particulate_filter_active_regeneration_inhibited_due_to_inhibit_switch`
128
- - `machine_insight_engine_air_filter_differential_pressure`
129
- - `machine_insight_engine_coolant_level`
130
- - `machine_insight_engine_coolant_pressure`
131
- - `machine_insight_engine_coolant_temperature`
132
- - `machine_insight_engine_exhaust_temperature`
133
- - `machine_insight_engine_fuel_delivery_pressure`
134
- - `machine_insight_engine_fuel_filter_differential_pressure`
135
- - `machine_insight_engine_fuel_rate`
136
- - `machine_insight_engine_fuel_temperature`
137
- - `machine_insight_engine_intake_air_pressure`
138
- - `machine_insight_engine_intake_air_temperature`
139
- - `machine_insight_engine_intake_manifold_pressure`
140
- - `machine_insight_engine_intake_manifold_temperature`
141
- - `machine_insight_engine_intercooler_temperature`
142
- - `machine_insight_engine_oil_filter_differential_pressure`
143
- - `machine_insight_engine_oil_level`
144
- - `machine_insight_engine_oil_pressure`
145
- - `machine_insight_engine_oil_temperature`
146
- - `machine_insight_engine_percent_load_at_current_speed`
147
- - `machine_insight_engine_speed`
148
- - `machine_insight_engine_status`
149
- - `machine_insight_engine_total_fuel_used`
150
- - `machine_insight_engine_total_idle_fuel_used`
151
- - `machine_insight_engine_trip_fuel`
152
- - `machine_insight_exhaust_system_high_temperature_lamp_command`
153
- - `machine_insight_fuel_level`
154
- - `machine_insight_fuel_tank_capacity`
155
- - `machine_insight_fuel_used_last_24`
156
- - `machine_insight_generator_total_kw_hours_export`
157
- - `machine_insight_hydraulic_oil_filter_restriction_switch`
158
- - `machine_insight_hydraulic_oil_level`
159
- - `machine_insight_hydraulic_pressure`
160
- - `machine_insight_hydraulic_temperature`
161
- - `machine_insight_impact`
162
- - `machine_insight_maximum_speed_last_24`
163
- - `machine_insight_operation_status`
164
- - `machine_insight_payload`
165
- - `machine_insight_payload_percentage`
166
- - `machine_insight_payload_temperature`
167
- - `machine_insight_pitch_angle`
168
- - `machine_insight_platform_elevated`
169
- - `machine_insight_platform_height`
170
- - `machine_insight_platform_height_percent`
171
- - `machine_insight_platform_stowed`
172
- - `machine_insight_rescue_mode_active`
173
- - `machine_insight_road_surface_temperature`
174
- - `machine_insight_roll_angle`
175
- - `machine_insight_seat_belt_switch`
176
- - `machine_insight_speed`
177
- - `machine_insight_stabilizers_deployed`
178
- - `machine_insight_total_power_take_off_hours`
179
- - `machine_insight_total_vehicle_distance`
180
- - `machine_insight_transmission_oil_temperature`
181
- - `machine_insight_water_in_fuel_indicator`
182
- - `machine_insight_wheel_based_vehicle_speed`
183
-
184
- ## PromQL Examples via GraphQL
185
-
186
- ### Calculate daily increases
187
- ```graphql
188
- query IncreaseOperatingHours($assetId: ID!, $start: DateTime!, $end: DateTime!, $step: Duration!) {
189
- asset(id: $assetId) {
190
- timeSeries {
191
- rangeQuery(
192
- query: "increase(machine_insight_cumulative_operating_hours[1d])",
193
- start: $start,
194
- end: $end,
195
- step: $step
196
- ) {
197
- data {
198
- ... on TimeSeriesMatrixData {
199
- result { values { timestamp value } }
200
- }
201
- }
202
- }
203
- }
204
- }
205
- }
206
- ```
207
-
208
- ### Filter with conditions
209
- ```graphql
210
- query HighFuelConsumption($assetId: ID!, $start: DateTime!, $end: DateTime!, $step: Duration!) {
211
- asset(id: $assetId) {
212
- timeSeries {
213
- rangeQuery(
214
- query: "increase(machine_insight_engine_total_fuel_used[1d]) > 13",
215
- start: $start,
216
- end: $end,
217
- step: $step
218
- ) {
219
- data {
220
- ... on TimeSeriesMatrixData {
221
- result { values { timestamp value } }
222
- }
223
- }
224
- }
225
- }
226
- }
227
- }
228
- ```
229
-
230
- ### Combine metrics
231
- ```graphql
232
- query FuelWithHighIdle($assetId: ID!, $start: DateTime!, $end: DateTime!, $step: Duration!) {
233
- asset(id: $assetId) {
234
- timeSeries {
235
- rangeQuery(
236
- query: "(increase(machine_insight_engine_total_fuel_used[1d]) > 13) and (increase(machine_insight_engine_total_idle_hours[1d]) > 4)",
237
- start: $start,
238
- end: $end,
239
- step: $step
240
- ) {
241
- data {
242
- ... on TimeSeriesMatrixData {
243
- result { values { timestamp value } }
244
- }
245
- }
246
- }
247
- }
248
- }
249
- }
250
- ```
251
-
252
- ## Key Points
253
-
254
- - **Always use fragments** for both `TimeSeriesMatrixData` and `TimeSeriesVectorData`
255
- - **Use PromQL functions** like `increase()`, `rate()`, `avg_over_time()`
256
- - **Filter at query level** with operators: `>`, `<`, `>=`, `<=`, `==`, `!=`
257
- - **Time windows** use brackets: `[1d]`, `[1h]`, `[15m]`
258
- - **Step intervals**: Choose based on data granularity needed
259
- - **Timestamps** are Unix timestamps in seconds
260
- - **Values** are returned as strings, convert to numbers as needed