Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions ProcessMaker/Jobs/RunScriptTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use ProcessMaker\Enums\ScriptExecutorType;
use ProcessMaker\Exception\ConfigurationException;
use ProcessMaker\Exception\ScriptException;
use ProcessMaker\Facades\Metrics;
use ProcessMaker\Facades\WorkflowManager;
use ProcessMaker\Managers\DataManager;
use ProcessMaker\Models\Process as Definitions;
Expand Down Expand Up @@ -111,6 +112,26 @@ public function action(ProcessRequestToken $token = null, ScriptTaskInterface $e
$response = $script->runScript($data, $configuration, $token->getId(), $errorHandling->timeout(), 1, $metadata);

$this->updateData($response);

Metrics::counter(
'script_task_completed_total',
'Total number of script tasks completed',
[
'activity_id',
'activity_name',
'process_id',
'request_id',
'script_executor',
]
)->inc(
[
'activity_id' => $element->getId(),
'activity_name' => $element->getName(),
'process_id' => $this->definitionsId,
'request_id' => $this->instanceId,
'script_executor' => $scriptExecutor ? $scriptExecutor->title : 'inline',
]
);
} catch (ConfigurationException $exception) {
$this->unlock();
$this->updateData(['output' => $exception->getMessageForData($token)]);
Expand Down
157 changes: 155 additions & 2 deletions resources/grafana/MainDashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,159 @@
],
"title": "Script Task Completion Time series",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "de96jy15v6qrkc"
},
"description": "Top Slowest Tasks",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"fieldMinMax": false,
"mappings": [],
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "ms"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 40
},
"id": 11,
"interval": "15s",
"options": {
"minVizHeight": 75,
"minVizWidth": 75,
"orientation": "auto",
"reduceOptions": {
"calcs": [],
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true,
"sizing": "auto"
},
"pluginVersion": "11.4.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "de96jy15v6qrkc"
},
"disableTextWrap": false,
"editorMode": "code",
"exemplar": false,
"expr": "topk(10, avg(processmaker_activity_execution_time_seconds_sum{element_type=\"scriptTask\"}) by (process_id, activity_name))",
"format": "time_series",
"fullMetaSearch": false,
"includeNullMetadata": true,
"instant": false,
"interval": "",
"legendFormat": "{{activity_name}} (process={{process_id}})",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Top Slowest Script Tasks",
"type": "gauge"
},
{
"datasource": {
"type": "prometheus",
"uid": "de96jy15v6qrkc"
},
"description": "Shows task completion distribution by activity and process to highlight execution patterns and identify key task volumes.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
}
},
"fieldMinMax": false,
"mappings": []
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 40
},
"id": 12,
"interval": "5m",
"options": {
"displayLabels": [
"percent"
],
"legend": {
"displayMode": "list",
"placement": "right",
"showLegend": true
},
"pieType": "pie",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "11.4.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "de96jy15v6qrkc"
},
"disableTextWrap": false,
"editorMode": "code",
"exemplar": false,
"expr": "sum by(activity_name, process_id) (processmaker_script_task_completed_total)",
"fullMetaSearch": false,
"includeNullMetadata": true,
"instant": false,
"legendFormat": "{{activity_name}} (process={{process_id}})",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Completion Count by Task and Process",
"type": "piechart"
}
],
"preload": false,
Expand All @@ -955,13 +1108,13 @@
"list": []
},
"time": {
"from": "now-6h",
"from": "now-30d",
"to": "now"
},
"timepicker": {},
"timezone": "browser",
"title": "ProcessMaker Dashboard",
"uid": "be96wxsnlmn7kc",
"version": 43,
"version": 49,
"weekStart": ""
}