Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Commit f1dbac1

Browse files
author
Chris Wiechmann
authored
Merge pull request #12 from mpentzek/master
Implemented circuitpath endpoint
2 parents 1a038c2 + 6318e33 commit f1dbac1

File tree

8 files changed

+453
-57
lines changed

8 files changed

+453
-57
lines changed

.github/workflows/traffic-monitor-api.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
name: Traffic-Monitor API
66

7+
78
on:
89
push:
910
branches: [ master ]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.DS_Store
22

3+
.vscode/launch.json

elk-traffic-monitor-api/endpoints/trafficMonitorApi.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
}
7777
]
7878
},
79-
"/router/service/{serviceID}/ops/stream/{transactionID}/*/circuitpath": {
79+
"/router/service/{serviceID}/ops/stream/{correlationID}/*/circuitpath": {
8080
"get": {
8181
"summary": "Retrieves circuitpath information",
8282
"tags": [],
@@ -87,10 +87,17 @@
8787
"type": "object",
8888
"properties": {}
8989
}
90+
},
91+
"500": {
92+
"description": "Internal Server Error",
93+
"schema": {
94+
"type": "object",
95+
"properties": {}
96+
}
9097
}
9198
},
9299
"operationId": "circuitpath",
93-
"description": "Retrieves information about the policy filters associated with the specified transactionID and serviceID",
100+
"description": "Retrieves information about the executed policies and filters associated to a transaction identified by its correlationID and serviceID",
94101
"x-flow": "trafficMonitorApi-circuitpath"
95102
},
96103
"parameters": [
@@ -103,7 +110,7 @@
103110
},
104111
{
105112
"type": "string",
106-
"name": "transactionID",
113+
"name": "correlationID",
107114
"in": "path",
108115
"required": true,
109116
"description": "identifies the transaction"

elk-traffic-monitor-api/flows/trafficMonitorApi-circuitpath.json

Lines changed: 143 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,49 @@
3030
"env"
3131
]
3232
},
33-
"start": "condition.1",
33+
"start": "javascript.2",
3434
"nodes": {
35-
"setcontext.1": {
36-
"type": "nodehandler://axway-flow/setcontext",
37-
"name": "Healthcheck API",
38-
"method": "setcontext",
35+
"elasticsearch.1": {
36+
"type": "nodehandler://@axway-api-builder-ext/api-builder-plugin-fn-elasticsearch/elasticsearch",
37+
"name": "Search",
38+
"method": "search",
3939
"parameters": [
4040
{
41-
"name": "value",
42-
"type": "array",
43-
"value": "[\n\t{\n\t\t\"policy\": \"Health Check\",\n\t\t\"execTime\": 3,\n\t\t\"filters\": [\n\t\t\t{\n\t\t\t\t\"espk\": \"DEFAULT_PRIMARY_VordelGateway_7.7.0:-1095086795812854131\",\n\t\t\t\t\"name\": \"Set Message\",\n\t\t\t\t\"type\": \"ChangeMessageFilter\",\n\t\t\t\t\"class\": \"com.vordel.circuit.conversion.ChangeMessageFilter\",\n\t\t\t\t\"status\": \"Pass\",\n\t\t\t\t\"filterTime\": 1588666217698,\n\t\t\t\t\"execTime\": 3\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"espk\": \"DEFAULT_PRIMARY_VordelGateway_7.7.0:-4282446533257395104\",\n\t\t\t\t\"name\": \"Reflect\",\n\t\t\t\t\"type\": \"ReflectFilter\",\n\t\t\t\t\"class\": \"com.vordel.circuit.net.ReflectFilter\",\n\t\t\t\t\"status\": \"Pass\",\n\t\t\t\t\"filterTime\": 1588666217698,\n\t\t\t\t\"execTime\": 0\n\t\t\t}\n\t\t]\n\t}\n]",
44-
"metaName": "value"
41+
"name": "query",
42+
"type": "jsonpath",
43+
"value": "$.elasticQuery",
44+
"metaName": "query",
45+
"metaDescription": "Defines the search definition using the Query DSL. Learn more: https://www.elastic.co/guide/en/elasticsearch/reference/7.x/query-dsl.html"
46+
},
47+
{
48+
"name": "index",
49+
"type": "jsonpath",
50+
"value": "$.index",
51+
"metaName": "index",
52+
"metaDescription": "Comma-separated list or wildcard expression of index names used to limit the request."
4553
}
4654
],
4755
"outputs": {
4856
"next": {
49-
"context": "$.circuit_payload",
57+
"context": "$.elasticsearch.result",
5058
"routes": [
51-
"http.1"
59+
"javascript.1"
5260
],
5361
"metaName": "Next"
62+
},
63+
"error": {
64+
"context": "$.error",
65+
"routes": [
66+
"http.1"
67+
],
68+
"metaName": "Error"
5469
}
5570
},
56-
"metaMethod": "Set Context"
71+
"metaMethod": "Search"
5772
},
58-
"http.1": {
73+
"http.2": {
5974
"type": "nodehandler://axway-flow/http",
60-
"name": "Set HTTP Response",
75+
"name": "HTTP Query Response",
6176
"method": "setresponse",
6277
"parameters": [
6378
{
@@ -70,7 +85,7 @@
7085
{
7186
"name": "body",
7287
"type": "jsonpath",
73-
"value": "$.circuit_payload",
88+
"value": "$.result",
7489
"metaName": "body",
7590
"metaDescription": "The response payload"
7691
}
@@ -84,66 +99,148 @@
8499
},
85100
"metaMethod": "Set HTTP Response"
86101
},
87-
"condition.1": {
88-
"type": "nodehandler://axway-flow/condition",
89-
"name": "Equals",
90-
"method": "equals",
102+
"javascript.1": {
103+
"type": "nodehandler://@axway/api-builder-plugin-fn-javascript/javascript",
104+
"name": "Format result",
105+
"method": "Execute",
91106
"parameters": [
92107
{
93-
"name": "source",
108+
"name": "data",
94109
"type": "jsonpath",
95-
"value": "$.params.transactionID",
96-
"metaName": "source",
97-
"metaDescription": "The input to test."
110+
"value": "$.elasticsearch.result.body.hits",
111+
"metaName": "data",
112+
"metaDescription": "The value to apply as the `data` argument to the JavaScript code. For objects and arrays, `data` is passed by reference."
98113
},
99114
{
100-
"name": "value",
115+
"name": "code",
101116
"type": "string",
102-
"value": "\"c8705e5ecc00adca32be7472\"",
103-
"metaName": "value",
104-
"metaDescription": "The value to test input against."
117+
"value": "\"let result = [];\\n //console.log(data);\\n \\n if(typeof data.hits[0] != \\\"undefined\\\"){\\n \\tresult = data.hits[0]._source.circuitPath;\\n }\\n \\n return result;\"",
118+
"metaName": "code",
119+
"metaDescription": "A JavaScript function body. Supports `await` and returning promises"
105120
}
106121
],
107122
"outputs": {
108-
"true": {
123+
"next": {
124+
"context": "$.result",
109125
"routes": [
110-
"setcontext.1"
126+
"http.2"
111127
],
112-
"context": "$.equals",
113-
"metaName": "True"
128+
"metaName": "Next"
114129
},
115-
"false": {
130+
"error": {
131+
"context": "$.error",
116132
"routes": [
117-
"setcontext.2"
133+
"http.1"
118134
],
119-
"context": "$.equals",
120-
"metaName": "False"
135+
"metaName": "Error"
121136
}
122137
},
123-
"metaMethod": "Equals"
138+
"metaMethod": "Execute"
124139
},
125-
"setcontext.2": {
126-
"type": "nodehandler://axway-flow/setcontext",
127-
"name": "ToDo API",
128-
"method": "setcontext",
140+
"javascript.2": {
141+
"type": "nodehandler://@axway/api-builder-plugin-fn-javascript/javascript",
142+
"name": "Define Index",
143+
"method": "Execute",
129144
"parameters": [
130145
{
131-
"name": "value",
132-
"type": "array",
133-
"value": "[\n\t{\n\t\t\"policy\": \"API Broker\",\n\t\t\"execTime\": 721,\n\t\t\"filters\": [\n\t\t\t{\n\t\t\t\t\"name\": \"Set service context\",\n\t\t\t\t\"type\": \"VApiServiceContextFilter\",\n\t\t\t\t\"class\": \"com.vordel.circuit.vapi.VApiServiceContextFilter\",\n\t\t\t\t\"status\": \"Pass\",\n\t\t\t\t\"filterTime\": 1588798042453,\n\t\t\t\t\"execTime\": 5\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"name\": \"Global Request Policy\",\n\t\t\t\t\"type\": \"CircuitDelegateFilter\",\n\t\t\t\t\"class\": \"com.vordel.circuit.CircuitDelegateFilter\",\n\t\t\t\t\"status\": \"Pass\",\n\t\t\t\t\"filterTime\": 1588798042464,\n\t\t\t\t\"execTime\": 9,\n\t\t\t\t\"subPaths\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"policy\": \"Trace\",\n\t\t\t\t\t\t\"execTime\": 9,\n\t\t\t\t\t\t\"filters\": [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"espk\": \"DEFAULT_PRIMARY_VordelGateway_7.7.0:-2330724604838128298\",\n\t\t\t\t\t\t\t\t\"name\": \"Trace Filter\",\n\t\t\t\t\t\t\t\t\"type\": \"TraceFilter\",\n\t\t\t\t\t\t\t\t\"class\": \"com.vordel.circuit.basic.TraceFilter\",\n\t\t\t\t\t\t\t\t\"status\": \"Pass\",\n\t\t\t\t\t\t\t\t\"filterTime\": 1588798042464,\n\t\t\t\t\t\t\t\t\"execTime\": 9\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"name\": \"Custom Routing\",\n\t\t\t\t\"type\": \"VApiCircuitDelegateFilter\",\n\t\t\t\t\"class\": \"com.vordel.apiportal.runtime.virtualized.VApiCircuitDelegateFilter\",\n\t\t\t\t\"status\": \"Pass\",\n\t\t\t\t\"filterTime\": 1588798043171,\n\t\t\t\t\"execTime\": 707,\n\t\t\t\t\"subPaths\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"policy\": \"Default API Proxy Routing\",\n\t\t\t\t\t\t\"execTime\": 707,\n\t\t\t\t\t\t\"filters\": [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"espk\": \"DEFAULT_PRIMARY_VordelGateway_7.7.0:4323849261363416160\",\n\t\t\t\t\t\t\t\t\"name\": \"Default Routing\",\n\t\t\t\t\t\t\t\t\"type\": \"SwitchFilter\",\n\t\t\t\t\t\t\t\t\"class\": \"com.vordel.circuit.switchcase.SwitchFilter\",\n\t\t\t\t\t\t\t\t\"status\": \"Pass\",\n\t\t\t\t\t\t\t\t\"filterTime\": 1588798043171,\n\t\t\t\t\t\t\t\t\"execTime\": 707,\n\t\t\t\t\t\t\t\t\"subPaths\": [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"policy\": \"Default API Proxy Routing\",\n\t\t\t\t\t\t\t\t\t\t\"execTime\": 674,\n\t\t\t\t\t\t\t\t\t\t\"filters\": [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"not-required-here\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"CircuitDelegateFilter\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"class\": \"com.vordel.circuit.CircuitDelegateFilter\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"status\": \"Pass\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"filterTime\": 1588798043171,\n\t\t\t\t\t\t\t\t\t\t\t\t\"execTime\": 674,\n\t\t\t\t\t\t\t\t\t\t\t\t\"subPaths\": [\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"policy\": \"Default Profile-based Routing\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"execTime\": 674,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"filters\": [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"espk\": \"DEFAULT_PRIMARY_VordelGateway_7.7.0:5735607394361826155\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"name\": \"Connect to URL\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"type\": \"ConnectToURLFilter\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"class\": \"com.vordel.circuit.net.ConnectToURLFilter\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"status\": \"Pass\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"filterTime\": 1588798043171,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"execTime\": 674\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t}\n]",
134-
"metaName": "value"
146+
"name": "code",
147+
"type": "string",
148+
"value": "\"let index = 'logstash-openlog';\\n if(data.config.testElasticIndex) {\\n index = data.config.testElasticIndex;\\n }\\n return index;\"",
149+
"metaName": "code",
150+
"metaDescription": "A JavaScript function body. Supports `await` and returning promises"
151+
},
152+
{
153+
"name": "data",
154+
"type": "jsonpath",
155+
"value": "$",
156+
"metaName": "data",
157+
"metaDescription": "The value to apply as the `data` argument to the JavaScript code. For objects and arrays, `data` is passed by reference."
135158
}
136159
],
137160
"outputs": {
138161
"next": {
139-
"context": "$.circuit_payload",
162+
"context": "$.index",
163+
"routes": [
164+
"javascript.3"
165+
],
166+
"metaName": "Next"
167+
},
168+
"error": {
169+
"context": "$.error",
140170
"routes": [
141171
"http.1"
142172
],
173+
"metaName": "Error"
174+
}
175+
},
176+
"metaMethod": "Execute"
177+
},
178+
"javascript.3": {
179+
"type": "nodehandler://@axway/api-builder-plugin-fn-javascript/javascript",
180+
"name": "Build Query",
181+
"method": "Execute",
182+
"parameters": [
183+
{
184+
"name": "data",
185+
"type": "jsonpath",
186+
"value": "$",
187+
"metaName": "data",
188+
"metaDescription": "The value to apply as the `data` argument to the JavaScript code. For objects and arrays, `data` is passed by reference."
189+
},
190+
{
191+
"name": "code",
192+
"type": "string",
193+
"value": "\"let elasticQuery = ({\\n \\\"bool\\\": {\\n \\\"must\\\": {\\n \\\"term\\\": {\\n \\\"correlationId\\\": data.params.correlationID\\n }\\n },\\n \\\"filter\\\": {\\n \\t\\\"term\\\": {\\n \\t\\t\\\"processInfo.serviceId\\\": data.params.serviceID\\n \\t}\\n \\t}\\n }\\n});\\n\\n return elasticQuery;\"",
194+
"metaName": "code",
195+
"metaDescription": "A JavaScript function body. Supports `await` and returning promises"
196+
}
197+
],
198+
"outputs": {
199+
"next": {
200+
"context": "$.elasticQuery",
201+
"routes": [
202+
"elasticsearch.1"
203+
],
204+
"metaName": "Next"
205+
},
206+
"error": {
207+
"context": "$.error",
208+
"routes": [
209+
"http.1"
210+
],
211+
"metaName": "Error"
212+
}
213+
},
214+
"metaMethod": "Execute"
215+
},
216+
"http.1": {
217+
"type": "nodehandler://axway-flow/http",
218+
"name": "HTTP Error Response",
219+
"method": "setresponse",
220+
"parameters": [
221+
{
222+
"name": "status",
223+
"type": "number",
224+
"value": "500",
225+
"metaName": "status",
226+
"metaDescription": "The HTTP status code"
227+
},
228+
{
229+
"name": "body",
230+
"type": "object",
231+
"value": "{\n \"errors\": [\n {\n \"code\": \"n.a\",\n \"message\": \"error occurred\" \n }\n ]\n}",
232+
"metaName": "body",
233+
"metaDescription": "The response payload"
234+
}
235+
],
236+
"outputs": {
237+
"next": {
238+
"context": "$.response",
239+
"routes": [],
143240
"metaName": "Next"
144241
}
145242
},
146-
"metaMethod": "Set Context"
243+
"metaMethod": "Set HTTP Response"
147244
}
148245
}
149246
}

0 commit comments

Comments
 (0)