How to get how many workflows executions between dates via API

Hi,

We need get the number of workflows executions for specific workflow between dates via API.

I tried with this:

curl -v -k -H “Content-Type: application/json” -X GET -d ‘{“action”: “linux.space_var_log”, “timestamp_gt”: “1562259600”, “timestamp_lt”: “156284800”, “runner”: “orquesta”’ https://stackstorm.com/api/v1/executions/?st2-api-key=XXXXXXXXXXXXXXXXXXXXXXXXX

But we get all actions inside workflows, how to filter with action_is_workflow=true or similar?

Not sure understand your question here. If linux.space_var_log is a workflow, it will return a list of workflows and doesn’t include individuals actions.

See following example, the individuals actions are not returned.

st2 run examples.orquesta-examples
....
id: 5d23d5eedb275939c1273578
action.ref: examples.orquesta-examples
parameters: None
status: succeeded
start_timestamp: Mon, 08 Jul 2019 23:46:54 UTC
end_timestamp: Mon, 08 Jul 2019 23:47:01 UTC
result:
  output: null
+-----------------------------+------------------------+------------+------------------------------+-------------------------------+
| id                          | status                 | task       | action                       | start_timestamp               |
+-----------------------------+------------------------+------------+------------------------------+-------------------------------+
| + 5d23d5eedb275939e6dfbc7f  | succeeded (2s elapsed) | basic      | examples.orquesta-basic      | Mon, 08 Jul 2019 23:46:54 UTC |
|    5d23d5efdb275939e6dfbc82 | succeeded (0s elapsed) | task1      | core.local                   | Mon, 08 Jul 2019 23:46:55 UTC |
| + 5d23d5f0db275939e6dfbc85  | succeeded (2s elapsed) | sequential | examples.orquesta-sequential | Mon, 08 Jul 2019 23:46:56 UTC |
|    5d23d5f0db275939e6dfbc88 | succeeded (1s elapsed) | task1      | core.echo                    | Mon, 08 Jul 2019 23:46:56 UTC |
|    5d23d5f1db275939e6dfbc8b | succeeded (0s elapsed) | task2      | core.echo                    | Mon, 08 Jul 2019 23:46:57 UTC |
|    5d23d5f2db275939e6dfbc8e | succeeded (0s elapsed) | task3      | core.echo                    | Mon, 08 Jul 2019 23:46:58 UTC |
| + 5d23d5f3db275939e6dfbc91  | succeeded (2s elapsed) | dataFlow   | examples.orquesta-data-flow  | Mon, 08 Jul 2019 23:46:59 UTC |
|    5d23d5f3db275939e6dfbc94 | succeeded (1s elapsed) | task1      | core.echo                    | Mon, 08 Jul 2019 23:46:59 UTC |
|    5d23d5f4db275939e6dfbc97 | succeeded (0s elapsed) | task2      | core.echo                    | Mon, 08 Jul 2019 23:47:00 UTC |
|    5d23d5f4db275939e6dfbc9a | succeeded (1s elapsed) | task3      | core.noop                    | Mon, 08 Jul 2019 23:47:00 UTC |
+-----------------------------+------------------------+------------+------------------------------+-------------------------------+

root@Community:/opt/stackstorm/packs/core/actions# curl -X GET -H  'X-Auth-Token: 88a7014ec54ce7959079d8cd60cc4f' 'http://127.0.0.1:9101/v1/executions?action=examples.orquesta-examples&runner=orquesta'
[
    {
        "action": {
            "tags": [],
            "uid": "action:examples:orquesta-examples",
            "metadata_file": "actions/orquesta-examples.yaml",
            "name": "orquesta-examples",
            "ref": "examples.orquesta-examples",
            "description": "Run a workflow that runs other workflows. Orcheseption.",
            "enabled": true,
            "entry_point": "workflows/orquesta-examples.yaml",
            "pack": "examples",
            "runner_type": "orquesta",
            "parameters": {},
            "output_schema": {},
            "notify": {},
            "id": "5d2393c7db27592622e5cc93"
        },
        "runner": {
            "name": "orquesta",
            "description": "A runner for executing orquesta workflow.",
            "uid": "runner_type:orquesta",
            "enabled": true,
            "runner_package": "orquesta_runner",
            "runner_module": "orquesta_runner",
            "runner_parameters": {
                "notify": {
                    "type": "array",
                    "description": "List of tasks to trigger notifications for.",
                    "uniqueItems": true,
                    "items": {
                        "type": "string",
                        "minLength": 1,
                        "pattern": "^\\w+$"
                    },
                    "default": []
                }
            },
            "output_key": "output",
            "output_schema": {
                "errors": {
                    "anyOf": [
                        {
                            "type": "object"
                        },
                        {
                            "type": "array"
                        }
                    ]
                },
                "output": {
                    "anyOf": [
                        {
                            "type": "object"
                        },
                        {
                            "type": "string"
                        },
                        {
                            "type": "integer"
                        },
                        {
                            "type": "number"
                        },
                        {
                            "type": "boolean"
                        },
                        {
                            "type": "array"
                        },
                        {
                            "type": "null"
                        }
                    ]
                }
            },
            "id": "5d236980db27593604ece604"
        },
        "liveaction": {
            "action": "examples.orquesta-examples",
            "action_is_workflow": true,
            "parameters": {},
            "callback": {},
            "runner_info": {
                "hostname": "Community",
                "pid": 14921
            },
            "id": "5d23d5eedb275939c1273577"
        },
        "status": "succeeded",
        "start_timestamp": "2019-07-08T23:46:54.543761Z",
        "end_timestamp": "2019-07-08T23:47:01.863390Z",
        "result": {
            "output": null
        },
        "context": {
            "user": "st2admin",
            "pack": "examples",
            "workflow_execution": "5d23d5eedb27593a49cf15a0"
        },
        "children": [
            "5d23d5eedb275939e6dfbc7f",
            "5d23d5f0db275939e6dfbc85",
            "5d23d5f3db275939e6dfbc91"
        ],
        "log": [
            {
                "timestamp": "2019-07-08T23:46:54.000000Z",
                "status": "requested"
            },
            {
                "timestamp": "2019-07-08T23:46:54.000000Z",
                "status": "scheduled"
            },
            {
                "timestamp": "2019-07-08T23:46:54.000000Z",
                "status": "running"
            },
            {
                "timestamp": "2019-07-08T23:47:01.000000Z",
                "status": "succeeded"
            }
        ],
        "web_url": "https://Community/#/history/5d23d5eedb275939c1273578/general",
        "id": "5d23d5eedb275939c1273578",
        "elapsed_seconds": 7.319629
    }
]

Hi @jinping, thanks for your answer.
If I run curl -k -X GET -H ‘X-Auth-Token: f954402fa4974aadb8b7bdba76aed27d’ ‘https://stackstorm.com/v1/executions?action=linux.space_var_log&runner=orquesta’ get the follow error:

<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.15.7</center>
</body>
</html>

I use st2 2.9.2

The easy way to identify an API request params based on https://api.stackstorm.com/api/v1/executions/ is to run st2web with Web Developer console turned on which will show all net requests with headers and whatnot.

A quick filter in StackStorm Web UI for the orchestra runner identified the following query in Web Developer console:

curl 'https://localhost/api/v1/executions?runner=orquesta&parent=null'

Just make sure you’re actually requesting your StackStorm instance instead of localhost in the URL.

1 Like

I wrongly generated the request with curl.

This works for me:

curl -k -H “Content-Type: application/json” -X GET “https://stackstorm.com/api/v1/executions?action=linux.space_var_log&runner=orquesta&parent=null&timestamp_gt=2019-06-29T00:00:00.000000Z&timestamp_lt=2019-06-30T00:00:00.000000Z&st2-api-key=xxxxxxxxxxxxxxxxxxxxxxxx