Elsa Document Approval Workflow (using VIsual Designer) always return 400 - elsa-workflows

I am following Elsa Workflow tutorial here: https://elsa-workflows.github.io/elsa-core/docs/next/guides/guides-document-approval#document-approval-workflow-visual-designer
I am using the docker version, which should be the latest.
But whenever I sent a POST request using postman, it always returns 400.
I believe I am following the tutorial exactly as described.
The workflow isn't being triggered at all..., I suspect http://localhost:13000/v2/documents is not the correct url.
Here is what I have designed.
This is what I POST using Postman.
This is the exported workflow definition.
{
"$id": "1",
"definitionId": "94e1b452fe8e4239aeff1cf779a65329",
"versionId": "cb2fbcfe31c44875b6f82b01ef477ea9",
"name": "VisualDocumentApprovalWorkflow",
"displayName": "Visual Document Approval Workflow",
"version": 3,
"variables": {
"$id": "2",
"data": {}
},
"customAttributes": {
"$id": "3",
"data": {}
},
"isSingleton": false,
"persistenceBehavior": "WorkflowBurst",
"deleteCompletedInstances": false,
"isPublished": true,
"isLatest": true,
"createdAt": "2022-11-23T08:43:45.6472218Z",
"activities": [
{
"$id": "4",
"activityId": "b1d82194-6a6b-4568-adde-382b16027c93",
"type": "HttpEndpoint",
"displayName": "HTTP Endpoint",
"persistWorkflow": false,
"loadWorkflowContext": false,
"saveWorkflowContext": false,
"properties": [
{
"$id": "5",
"name": "Path",
"expressions": {
"$id": "6",
"Literal": "/v2/documents/"
}
},
{
"$id": "7",
"name": "Methods",
"expressions": {
"$id": "8",
"Json": "[\"POST\"]"
}
},
{
"$id": "9",
"name": "ReadContent",
"expressions": {
"$id": "10",
"Literal": "true"
}
},
{
"$id": "11",
"name": "TargetType",
"expressions": {
"$id": "12"
}
},
{
"$id": "13",
"name": "Schema",
"syntax": "Literal",
"expressions": {
"$id": "14",
"Literal": ""
}
},
{
"$id": "15",
"name": "Authorize",
"expressions": {
"$id": "16",
"Literal": "false"
}
},
{
"$id": "17",
"name": "Policy",
"expressions": {
"$id": "18",
"Literal": "adaa"
}
}
],
"propertyStorageProviders": {
"$id": "19"
}
},
{
"$id": "20",
"activityId": "2e7f8800-d49f-4485-b47b-0c9f3cb82a48",
"type": "SetVariable",
"displayName": "Set Variable",
"persistWorkflow": false,
"loadWorkflowContext": false,
"saveWorkflowContext": false,
"properties": [
{
"$id": "21",
"name": "VariableName",
"expressions": {
"$id": "22",
"Literal": "Document"
}
},
{
"$id": "23",
"name": "Value",
"syntax": "JavaScript",
"expressions": {
"$id": "24",
"Literal": "input.Body",
"JavaScript": "input.Body"
}
}
],
"propertyStorageProviders": {
"$id": "25"
}
},
{
"$id": "26",
"activityId": "b10ffb0d-c9ae-439a-86fa-b4351294666d",
"type": "SendEmail",
"displayName": "Send Email",
"persistWorkflow": false,
"loadWorkflowContext": false,
"saveWorkflowContext": false,
"properties": [
{
"$id": "27",
"name": "From",
"expressions": {
"$id": "28",
"Literal": "workflow#acme.com"
}
},
{
"$id": "29",
"name": "To",
"expressions": {
"$id": "30",
"Json": "[\"josh#acme.com\"]"
}
},
{
"$id": "31",
"name": "Subject",
"syntax": "Liquid",
"expressions": {
"$id": "32",
"Literal": "Document received from {{Variables.Document.Author.Name}}",
"Liquid": "Document received from {{Variables.Document.Author.Name}}"
}
},
{
"$id": "33",
"name": "Attachments",
"expressions": {
"$id": "34"
}
},
{
"$id": "35",
"name": "Body",
"expressions": {
"$id": "36",
"Literal": "Document from {{ Variables.Document.Author.Name }} received for review.<br>Approve or Reject"
}
},
{
"$id": "37",
"name": "Cc",
"expressions": {
"$id": "38"
}
},
{
"$id": "39",
"name": "Bcc",
"expressions": {
"$id": "40"
}
}
],
"propertyStorageProviders": {
"$id": "41"
}
},
{
"$id": "42",
"activityId": "90942864-bd26-4309-82fd-51f27b8e3615",
"type": "WriteHttpResponse",
"displayName": "HTTP Response",
"persistWorkflow": false,
"loadWorkflowContext": false,
"saveWorkflowContext": false,
"properties": [
{
"$id": "43",
"name": "Content",
"expressions": {
"$id": "44",
"Literal": "<h1>Request for Approval Sent</h1><p>Your document has been received and will be reviewed shortly.</p>"
}
},
{
"$id": "45",
"name": "ContentType",
"expressions": {
"$id": "46",
"Literal": "text/html"
}
},
{
"$id": "47",
"name": "StatusCode",
"expressions": {
"$id": "48",
"Literal": "OK"
}
},
{
"$id": "49",
"name": "CharSet",
"expressions": {
"$id": "50",
"Literal": ""
}
},
{
"$id": "51",
"name": "ResponseHeaders",
"expressions": {
"$id": "52"
}
}
],
"propertyStorageProviders": {
"$id": "53"
}
},
{
"$id": "54",
"activityId": "c62c8ff0-db76-4dea-b1a6-6cc138415b17",
"type": "Fork",
"displayName": "Fork",
"persistWorkflow": false,
"loadWorkflowContext": false,
"saveWorkflowContext": false,
"properties": [
{
"$id": "55",
"name": "Branches",
"expressions": {
"$id": "56",
"Json": "[\"Approve\",\"Reject\",\"Remind\"]"
}
}
],
"propertyStorageProviders": {
"$id": "57"
}
},
{
"$id": "58",
"activityId": "aa201fb5-a50f-44b1-989f-7a7b57b3b52d",
"type": "SignalReceived",
"displayName": "Signal Received",
"persistWorkflow": false,
"loadWorkflowContext": false,
"saveWorkflowContext": false,
"properties": [
{
"$id": "59",
"name": "Signal",
"expressions": {
"$id": "60",
"Literal": "Approve"
}
}
],
"propertyStorageProviders": {
"$id": "61"
}
},
{
"$id": "62",
"activityId": "615f0e0d-9f7a-4a2f-ab9e-97b3bea10cbe",
"type": "SendEmail",
"displayName": "Send Email",
"persistWorkflow": false,
"loadWorkflowContext": false,
"saveWorkflowContext": false,
"properties": [
{
"$id": "63",
"name": "From",
"expressions": {
"$id": "64",
"Literal": "workflow#acme.com"
}
},
{
"$id": "65",
"name": "To",
"syntax": "JavaScript",
"expressions": {
"$id": "66",
"Json": "[\"[Document.Author.Email]\"]",
"JavaScript": "[Document.Author.Email]"
}
},
{
"$id": "67",
"name": "Subject",
"syntax": "Liquid",
"expressions": {
"$id": "68",
"Liquid": "Document {{ Variables.Document.Id }} Approved!"
}
},
{
"$id": "69",
"name": "Attachments",
"expressions": {
"$id": "70"
}
},
{
"$id": "71",
"name": "Body",
"syntax": "Liquid",
"expressions": {
"$id": "72",
"Liquid": "Great job {{ Variables.Document.Author.Name }}, that document is perfect."
}
},
{
"$id": "73",
"name": "Cc",
"expressions": {
"$id": "74"
}
},
{
"$id": "75",
"name": "Bcc",
"expressions": {
"$id": "76"
}
}
],
"propertyStorageProviders": {
"$id": "77"
}
},
{
"$id": "78",
"activityId": "af52dae7-254b-4602-be35-0c0ef23a4ba5",
"type": "SignalReceived",
"displayName": "Signal Received",
"persistWorkflow": false,
"loadWorkflowContext": false,
"saveWorkflowContext": false,
"properties": [
{
"$id": "79",
"name": "Signal",
"expressions": {
"$id": "80",
"Literal": "Reject"
}
}
],
"propertyStorageProviders": {
"$id": "81"
}
},
{
"$id": "82",
"activityId": "ce2c17ff-cb9e-430a-a11e-9c92f0f4aa46",
"type": "SendEmail",
"displayName": "Send Email",
"persistWorkflow": false,
"loadWorkflowContext": false,
"saveWorkflowContext": false,
"properties": [
{
"$id": "83",
"name": "From",
"expressions": {
"$id": "84",
"Literal": "workflow#acme.com"
}
},
{
"$id": "85",
"name": "To",
"syntax": "JavaScript",
"expressions": {
"$id": "86",
"JavaScript": "[Document.Author.Email]"
}
},
{
"$id": "87",
"name": "Subject",
"syntax": "Liquid",
"expressions": {
"$id": "88",
"Literal": "Document {{ Variables.Document.Id }} Rejected",
"JavaScript": "Document {{ Variables.Document.Id }} Rejected"
}
},
{
"$id": "89",
"name": "Attachments",
"expressions": {
"$id": "90"
}
},
{
"$id": "91",
"name": "Body",
"syntax": "Liquid",
"expressions": {
"$id": "92",
"Liquid": "Nice try {{ Variables.Document.Author.Name }}, but that document needs work."
}
},
{
"$id": "93",
"name": "Cc",
"expressions": {
"$id": "94"
}
},
{
"$id": "95",
"name": "Bcc",
"expressions": {
"$id": "96"
}
}
],
"propertyStorageProviders": {
"$id": "97"
}
},
{
"$id": "98",
"activityId": "0be8d291-f88e-4db6-866e-fc722df70b27",
"type": "Timer",
"displayName": "Timer",
"persistWorkflow": false,
"loadWorkflowContext": false,
"saveWorkflowContext": false,
"properties": [
{
"$id": "99",
"name": "Timeout",
"syntax": "JavaScript",
"expressions": {
"$id": "100",
"JavaScript": "Duration.FromSeconds(10)"
}
}
],
"propertyStorageProviders": {
"$id": "101"
}
},
{
"$id": "102",
"activityId": "01b73005-d48e-46eb-88ae-55a08f96c356",
"type": "SendEmail",
"displayName": "Send Email",
"persistWorkflow": false,
"loadWorkflowContext": false,
"saveWorkflowContext": false,
"properties": [
{
"$id": "103",
"name": "From",
"expressions": {
"$id": "104",
"Literal": "workflow#acme.com"
}
},
{
"$id": "105",
"name": "To",
"expressions": {
"$id": "106",
"Json": "[\"josh#acme.com\"]"
}
},
{
"$id": "107",
"name": "Subject",
"syntax": "Liquid",
"expressions": {
"$id": "108",
"Liquid": "{{ Variables.Document.Author.Name }} is waiting for your review!"
}
},
{
"$id": "109",
"name": "Attachments",
"expressions": {
"$id": "110"
}
},
{
"$id": "111",
"name": "Body",
"syntax": "Liquid",
"expressions": {
"$id": "112",
"Liquid": "Don't forget to review document {{ Variables.Document.Id }}.<br>Approve or Reject"
}
},
{
"$id": "113",
"name": "Cc",
"expressions": {
"$id": "114"
}
},
{
"$id": "115",
"name": "Bcc",
"expressions": {
"$id": "116"
}
}
],
"propertyStorageProviders": {
"$id": "117"
}
},
{
"$id": "118",
"activityId": "e1c0aedb-c75b-4386-a20a-b0121f3a1421",
"type": "Join",
"displayName": "Join",
"persistWorkflow": false,
"loadWorkflowContext": false,
"saveWorkflowContext": false,
"properties": [
{
"$id": "119",
"name": "EagerJoin",
"expressions": {
"$id": "120"
}
},
{
"$id": "121",
"name": "Mode",
"expressions": {
"$id": "122",
"Literal": "WaitAny"
}
}
],
"propertyStorageProviders": {
"$id": "123"
}
},
{
"$id": "124",
"activityId": "84247af4-66a8-41ab-a442-b72b1d256154",
"type": "WriteHttpResponse",
"displayName": "HTTP Response",
"persistWorkflow": false,
"loadWorkflowContext": false,
"saveWorkflowContext": false,
"properties": [
{
"$id": "125",
"name": "Content",
"expressions": {
"$id": "126",
"Literal": "Thanks for the hard work!"
}
},
{
"$id": "127",
"name": "ContentType",
"expressions": {
"$id": "128",
"Literal": "text/html"
}
},
{
"$id": "129",
"name": "StatusCode",
"expressions": {
"$id": "130",
"Literal": "OK"
}
},
{
"$id": "131",
"name": "CharSet",
"expressions": {
"$id": "132",
"Literal": ""
}
},
{
"$id": "133",
"name": "ResponseHeaders",
"expressions": {
"$id": "134"
}
}
],
"propertyStorageProviders": {
"$id": "135"
}
}
],
"connections": [
{
"$id": "136",
"sourceActivityId": "b1d82194-6a6b-4568-adde-382b16027c93",
"targetActivityId": "2e7f8800-d49f-4485-b47b-0c9f3cb82a48",
"outcome": "Done"
},
{
"$id": "137",
"sourceActivityId": "2e7f8800-d49f-4485-b47b-0c9f3cb82a48",
"targetActivityId": "b10ffb0d-c9ae-439a-86fa-b4351294666d",
"outcome": "Done"
},
{
"$id": "138",
"sourceActivityId": "b10ffb0d-c9ae-439a-86fa-b4351294666d",
"targetActivityId": "90942864-bd26-4309-82fd-51f27b8e3615",
"outcome": "Done"
},
{
"$id": "139",
"sourceActivityId": "90942864-bd26-4309-82fd-51f27b8e3615",
"targetActivityId": "c62c8ff0-db76-4dea-b1a6-6cc138415b17",
"outcome": "Done"
},
{
"$id": "140",
"sourceActivityId": "c62c8ff0-db76-4dea-b1a6-6cc138415b17",
"targetActivityId": "aa201fb5-a50f-44b1-989f-7a7b57b3b52d",
"outcome": "Approve"
},
{
"$id": "141",
"sourceActivityId": "aa201fb5-a50f-44b1-989f-7a7b57b3b52d",
"targetActivityId": "615f0e0d-9f7a-4a2f-ab9e-97b3bea10cbe",
"outcome": "Done"
},
{
"$id": "142",
"sourceActivityId": "c62c8ff0-db76-4dea-b1a6-6cc138415b17",
"targetActivityId": "af52dae7-254b-4602-be35-0c0ef23a4ba5",
"outcome": "Reject"
},
{
"$id": "143",
"sourceActivityId": "af52dae7-254b-4602-be35-0c0ef23a4ba5",
"targetActivityId": "ce2c17ff-cb9e-430a-a11e-9c92f0f4aa46",
"outcome": "Done"
},
{
"$id": "144",
"sourceActivityId": "c62c8ff0-db76-4dea-b1a6-6cc138415b17",
"targetActivityId": "0be8d291-f88e-4db6-866e-fc722df70b27",
"outcome": "Remind"
},
{
"$id": "145",
"sourceActivityId": "0be8d291-f88e-4db6-866e-fc722df70b27",
"targetActivityId": "01b73005-d48e-46eb-88ae-55a08f96c356",
"outcome": "Done"
},
{
"$id": "146",
"sourceActivityId": "01b73005-d48e-46eb-88ae-55a08f96c356",
"targetActivityId": "0be8d291-f88e-4db6-866e-fc722df70b27",
"outcome": "Done"
},
{
"$id": "147",
"sourceActivityId": "615f0e0d-9f7a-4a2f-ab9e-97b3bea10cbe",
"targetActivityId": "e1c0aedb-c75b-4386-a20a-b0121f3a1421",
"outcome": "Done"
},
{
"$id": "148",
"sourceActivityId": "ce2c17ff-cb9e-430a-a11e-9c92f0f4aa46",
"targetActivityId": "e1c0aedb-c75b-4386-a20a-b0121f3a1421",
"outcome": "Done"
},
{
"$id": "149",
"sourceActivityId": "e1c0aedb-c75b-4386-a20a-b0121f3a1421",
"targetActivityId": "84247af4-66a8-41ab-a442-b72b1d256154",
"outcome": "Done"
}
],
"id": "cb2fbcfe31c44875b6f82b01ef477ea9"
}

Nevermind..., the correct url is http://localhost:13000/workflows/v2/documents instead of http://localhost:13000/v2/documents.
I found this by trial and error.
I will submit a PR to amend the documentation.

Related

How can I read array data in table format using Talend ETL?

Hello,
I'm new in Talend. Want to extract data from file to table format.
What will steps to retrieve data in column format from below data -( _id,projectName,title,value)
Array data -
[
{
"_id": 1,
"projectName": "Test",
"languageId": 1,
"userId": 100,
"userDetails": {
"location": {
"coordinates": [
19.2666415,
72.9814762
]
},
"serialNumber": "5ab24f2d2ce1"
},
"questionDetails": [
{
"_id": 1,
"title": "QuestionName 01",
"description": "QuestionName 01",
"question": "QuestionName 01",
"type": "Radio",
"optionMap": {
"1": "Option 01",
"2": "Option 01"
},
"response": {
"value": [
"2"
]
},
"responseExtension": {
"comments": "",
"reviews": "",
"summary": "",
"imageURLs": [
],
"videoURLs": [
],
"audioURLs": [
]
}
}
],
"createdDate": {
"$date": {
"$numberLong": "1603802807000"
}
},
"lastModifiedDate": {
"$date": {
"$numberLong": "1603802807000"
}
},
"_class": "dummy"
},
{
"_id": 2,
"projectName": "Test",
"languageId": 1,
"userId": 101,
"surveyId": 1,
"sectionId": 10,
"userDetails": {
"location": {
"coordinates": [
19.0564471,
72.9033019
]
},
"serialNumber": "d8ee581588c2"
},
"questionDetails": [
{
"_id": 11,
"title": "QuestionName 02",
"description": "QuestionName 02",
"question": "QuestionName 02",
"type": "Radio",
"optionMap": {
"1": "Option 02",
"2": "Option 02"
},
"response": {
"value": [
"1"
]
},
"responseExtension": {
"comments": "",
"reviews": "",
"summary": "",
"imageURLs": [
],
"videoURLs": [
],
"audioURLs": [
]
}
}
],
"isActive": false,
"communication": {
},
"questionIndex": 0,
"isAboutToFinish": false,
"managingStatus": "archived",
"sectionIds": [
],
"questionResponses": [
],
"createdDate": {
"$date": {
"$numberLong": "1603372059000"
}
},
"lastModifiedDate": {
"$date": {
"$numberLong": "1658313691000"
}
},
"_class": "dummy"
}
]

laravel http client to customize data

{
"1": {
"outcomes": {
"1.1": {
"outcome": "3.35",
"handicap": null,
"state": "active",
"label": "1"
},
"1.2": {
"outcome": "3.05",
"handicap": null,
"state": "active",
"label": "X"
},
"1.3": {
"outcome": "1.73",
"handicap": null,
"state": "active",
"label": "2"
}
},
"code": "20873",
"mbc": "MBS 1"
},
"3": {
"outcomes": {
"3.1": {
"outcome": "1.52",
"handicap": null,
"state": "active",
"label": "1-X"
},
"3.2": {
"outcome": "1.16",
"handicap": null,
"state": "active",
"label": "1-2"
},
"3.3": {
"outcome": "1.16",
"handicap": null,
"state": "active",
"label": "X-2"
}
},
"code": "20877",
"mbc": "MBS 1"
},
"4": {
"outcomes": {
"7.1": {
"outcome": "3.60",
"handicap": null,
"state": "active",
"label": "1"
},
"7.2": {
"outcome": "1.92",
"handicap": null,
"state": "active",
"label": "X"
},
"7.3": {
"outcome": "2.23",
"handicap": null,
"state": "active",
"label": "2"
}
},
"code": "21873",
"mbc": "MBS 1"
},
}
I am using Laravel http client.
I want to edit this data as below, but I don't know how to do it.
While pulling json data with HTTP Client, I want to edit and show this
data as below. I hope I was able to explain my problem.
Thank you in advance for your help.
{
"1.1": {
"outcome": "3.35",
"handicap": null,
"state": "active",
"label": "1",
"code": "20873",
"mbc": "MBS 1"
},
"1.2": {
"outcome": "3.05",
"handicap": null,
"state": "active",
"label": "X",
"code": "20873",
"mbc": "MBS 1"
},
"1.3": {
"outcome": "1.73",
"handicap": null,
"state": "active",
"label": "2",
"code": "20873",
"mbc": "MBS 1"
},
"3.1": {
"outcome": "1.52",
"handicap": null,
"state": "active",
"label": "1-X",
"code": "20877",
"mbc": "MBS 1"
},
"3.2": {
"outcome": "1.16",
"handicap": null,
"state": "active",
"label": "1-2",
"code": "20877",
"mbc": "MBS 1"
},
"3.3": {
"outcome": "1.16",
"handicap": null,
"state": "active",
"label": "X-2",
"code": "20877",
"mbc": "MBS 1"
},
"7.1": {
"outcome": "3.60",
"handicap": null,
"state": "active",
"label": "1",
"code": "21873",
"mbc": "MBS 1"
},
"7.2": {
"outcome": "1.92",
"handicap": null,
"state": "active",
"label": "X",
"code": "21873",
"mbc": "MBS 1"
},
"7.3": {
"outcome": "2.23",
"handicap": null,
"state": "active",
"label": "2",
"code": "21873",
"mbc": "MBS 1"
}
}
My code:
$json = collect($json['data']['markets']);
$json = $json->map(function ($item, $key) {
return $item;
});
return $json;
How can we do it with "Laravel collect $json->map(function ... " ?
$json = collect($json);
$final = [];
foreach ($json as $item) {
foreach ($item["outcomes"] as $key => $ver) {
$ver["code"] = $item["code"];
$ver["mbc"] = $item["mbc"];
array_push($final, [$key => $ver]);
}
};
return $final;
please check this way
Surprisingly not easy if you really insist on using map(), the hard part is flattening the array afterwards, as flattening relies on the keys in each dimension being unique, which may not always be the case.
For example, you could do this:
collect($json)->flatMap(
fn ($group) => [
collect($group->outcomes)->each(function ($outcome) use ($group) {
$outcome->code = $group->code;
$outcome->mbc = $group->mbc;
}),
]
)->collapse()
But this would return unexpected results if your input JSON contained keys that are the same, for example:
{
"1": {
"outcomes": {
"same-key": {
"outcome": "3.35",
}
},
"code": "20873",
"mbc": "MBS 1"
},
"3": {
"outcomes": {
"same-key": {
"outcome": "1.52",
}
},
"code": "20877",
"mbc": "MBS 1"
}
}
I think the second one would overwrite the first.

Elasticsearch document sorting based on nested values

I have the following data indexed in my elasticsearch version 7.4.
[
{
"users": [
{
"age": "31",
"dept": "IT",
"city": "Chennai"
},
{
"age": "25",
"dept": "Accounts",
"city": "Bengaluru"
},
{
"age": "26",
"dept": "Finance",
"city": "Kochi"
}
],
"isActive": true
},
{
"users": [
{
"age": "23",
"dept": "IT",
"city": "Chennai"
},
{
"age": "22",
"dept": "Finance",
"city": "Kochi"
},
{
"age": "21",
"dept": "Accounts",
"city": "Bengaluru"
}
],
"isActive": true
},
{
"users": [
{
"age": "28",
"dept": "IT",
"city": "Chennai"
},
{
"age": "22",
"dept": "Finance",
"city": "Kochi"
},
{
"age": "21",
"dept": "Accounts",
"city": "Bengaluru"
}
],
"isActive": true
},
{
"users": [
{
"age": "31",
"dept": "IT",
"city": "Kochi"
},
{
"age": "25",
"dept": "Finance",
"city": "Bengaluru"
},
{
"age": "26",
"dept": "Accounts",
"city": "Chennai"
}
],
"isActive": true
},
{
"users": [
{
"age": "21",
"dept": "IT",
"city": "Kochi"
},
{
"age": "45",
"dept": "Accounts",
"city": "Bengaluru"
},
{
"age": "26",
"dept": "Finance",
"city": "Chennai"
}
],
"isActive": false
}
]
the users is nested type
I want to sort the documents based on the following condition
isActive == true && users.dept == "IT" && users.city == "Chennai" with the age sorts in ascending
I am expecting the following result
[
{
"users": [
{
"age": "23",
"dept": "IT",
"city": "Chennai"
},
{
"age": "22",
"dept": "Finance",
"city": "Kochi"
},
{
"age": "21",
"dept": "Accounts",
"city": "Bengaluru"
}
],
"isActive": true
},
{
"users": [
{
"age": "28",
"dept": "IT",
"city": "Chennai"
},
{
"age": "22",
"dept": "Finance",
"city": "Kochi"
},
{
"age": "21",
"dept": "Accounts",
"city": "Bengaluru"
}
],
"isActive": true
},
{
"users": [
{
"age": "31",
"dept": "IT",
"city": "Chennai"
},
{
"age": "25",
"dept": "Accounts",
"city": "Bengaluru"
},
{
"age": "26",
"dept": "Finance",
"city": "Kochi"
}
],
"isActive": true
},
{
"users": [
{
"age": "31",
"dept": "IT",
"city": "Kochi"
},
{
"age": "25",
"dept": "Finance",
"city": "Bengaluru"
},
{
"age": "26",
"dept": "Accounts",
"city": "Chennai"
}
],
"isActive": true
}
]
I tried with script based sorting, I couldn't able to achieve the result.
Please help me to sort this out.
Thanks in advance.

jira-trigger-webhook-receiver throws JSONException: JSONObject["name"] not found

We have JIRA triggering Jenkins builds using jira-trigger plugin of Jenkins. AS of yesterday(2019-07-10) it was all working but today it is not triggering any builds.
I have enabled following logging (to all) in Jenkins and checked the logs
*com.ceilfors.jenkins.plugins.jiratrigger.*
com.ceilfors.jenkins.plugins.jiratrigger.webhook.JiraWebhook
com.ceilfors.jenkins.plugins.jiratrigger.JiraCommentTrigger
com.ceilfors.jenkins.plugins.jiratrigger.JiraTrigger
com.ceilfors.jenkins.plugins.jiratrigger.JiraTriggerExecutor*
I could see Jira webhook is sending valid JSON and same is failing at Jenkins stating this error: org.codehaus.jettison.json.JSONException: JSONObject["name"] not found.
Error while serving https://localhost/jira-trigger-webhook-receiver/
org.codehaus.jettison.json.JSONException: JSONObject["name"] not found.
at org.codehaus.jettison.json.JSONObject.get(JSONObject.java:360)
at org.codehaus.jettison.json.JSONObject.getString(JSONObject.java:487)
at com.atlassian.jira.rest.client.internal.json.JsonParseUtil.parseBasicUser(JsonParseUtil.java:192)
at com.atlassian.jira.rest.client.internal.json.CommentJsonParser.parse(CommentJsonParser.java:37)
at com.atlassian.jira.rest.client.internal.json.CommentJsonParser$parse.call(Unknown Source)
at com.ceilfors.jenkins.plugins.jiratrigger.webhook.WebhookCommentEventJsonParser.parse(WebhookCommentEventJsonParser.groovy:40)
at com.ceilfors.jenkins.plugins.jiratrigger.webhook.WebhookCommentEventJsonParser$parse.call(Unknown Source)
at com.ceilfors.jenkins.plugins.jiratrigger.webhook.JiraWebhook.processEvent(JiraWebhook.groovy:71)
at com.ceilfors.jenkins.plugins.jiratrigger.webhook.JiraWebhook$processEvent.callCurrent(Unknown Source)
at com.ceilfors.jenkins.plugins.jiratrigger.webhook.JiraWebhook.doIndex(JiraWebhook.groovy:51)
at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)
Caused: java.lang.reflect.InvocationTargetException
at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:400)
at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:408)
at org.kohsuke.stapler.interceptor.RequirePOST$Processor.invoke(RequirePOST.java:77)
at org.kohsuke.stapler.PreInvokeInterceptedFunction.invoke(PreInvokeInterceptedFunction.java:26)
at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:212)
at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:145)
at org.kohsuke.stapler.IndexDispatcher.dispatch(IndexDispatcher.java:27)
JSON Received:
{
"timestamp": 1562845569917,
"webhookEvent": "comment_created",
"comment": {
"self": "https://my.atlassian.net/rest/api/2/issue/12815/comment/19186",
"id": "19186",
"author": {
"self": "https://my.atlassian.net/rest/api/2/user?accountId=1234567890",
"accountId": "1234567890",
"emailAddress": "\"?\"",
"avatarUrls": {
"48x48": "https://alocal.net/initials/PM-1.png?size=48&s=48",
"24x24": "https://alocal.net/initials/PM-1.png?size=24&s=24",
"16x16": "https://alocal.net/initials/PM-1.png?size=16&s=16",
"32x32": "https://alocal.net/initials/PM-1.png?size=32&s=32"
},
"displayName": "admin",
"active": true,
"timeZone": "Asia/Calcutta",
"accountType": "atlassian"
},
"body": "deploy_staging",
"updateAuthor": {
"self": "https://my.atlassian.net/rest/api/2/user?accountId=1234567890",
"accountId": "1234567890",
"emailAddress": "\"?\"",
"avatarUrls": {
"48x48": "https://alocal.net/initials/PM-1.png?size=48&s=48",
"24x24": "https://alocal.net/initials/PM-1.png?size=24&s=24",
"16x16": "https://alocal.net/initials/PM-1.png?size=16&s=16",
"32x32": "https://alocal.net/initials/PM-1.png?size=32&s=32"
},
"displayName": "admin",
"active": true,
"timeZone": "Asia/Calcutta",
"accountType": "atlassian"
},
"created": "2019-07-11T17:16:09.917+0530",
"updated": "2019-07-11T17:16:09.917+0530",
"jsdPublic": true
},
"issue": {
"id": "12815",
"self": "https://my.atlassian.net/rest/api/2/issue/12815",
"key": "DEVOPS-160",
"fields": {
"summary": "Deploy - Test",
"issuetype": {
"self": "https://my.atlassian.net/rest/api/2/issuetype/10081",
"id": "10081",
"description": "",
"iconUrl": "https://my.atlassian.net/secure/viewavatar?size=medium&avatarId=10304&avatarType=issuetype",
"name": "Deployment",
"subtask": false,
"avatarId": 10304
},
"project": {
"self": "https://my.atlassian.net/rest/api/2/project/10032",
"id": "10032",
"key": "DEVOPS",
"name": "Test Ops",
"projectTypeKey": "software",
"simplified": false,
"avatarUrls": {
"48x48": "https://my.atlassian.net/secure/projectavatar?pid=10032&avatarId=10517",
"24x24": "https://my.atlassian.net/secure/projectavatar?size=small&s=small&pid=10032&avatarId=10517",
"16x16": "https://my.atlassian.net/secure/projectavatar?size=xsmall&s=xsmall&pid=10032&avatarId=10517",
"32x32": "https://my.atlassian.net/secure/projectavatar?size=medium&s=medium&pid=10032&avatarId=10517"
},
"projectCategory": {
"self": "https://my.atlassian.net/rest/api/2/projectCategory/10006",
"id": "10006",
"description": "Operations",
"name": "Operations"
}
},
"assignee": {
"self": "https://my.atlassian.net/rest/api/2/user?accountId=1234567890",
"name": "phani.k",
"key": "phani.k",
"accountId": "1234567890",
"emailAddress": "phani.k#synup.com",
"avatarUrls": {
"48x48": "https://alocal.net/1234567890/dfe77db8-e320-4c3e-a074-3d79892a5c6d/128?size=48&s=48",
"24x24": "https://alocal.net/1234567890/dfe77db8-e320-4c3e-a074-3d79892a5c6d/128?size=24&s=24",
"16x16": "https://alocal.net/1234567890/dfe77db8-e320-4c3e-a074-3d79892a5c6d/128?size=16&s=16",
"32x32": "https://alocal.net/1234567890/dfe77db8-e320-4c3e-a074-3d79892a5c6d/128?size=32&s=32"
},
"displayName": "admin",
"active": true,
"timeZone": "Asia/Kolkata",
"accountType": "atlassian"
},
"priority": {
"self": "https://my.atlassian.net/rest/api/2/priority/3",
"iconUrl": "https://my.atlassian.net/images/icons/priorities/medium.svg",
"name": "Medium",
"id": "3"
},
"status": {
"self": "https://my.atlassian.net/rest/api/2/status/10118",
"description": "Run all feasibility checks",
"iconUrl": "https://my.atlassian.net/",
"name": "In Progress",
"id": "10118",
"statusCategory": {
"self": "https://my.atlassian.net/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
}
}
}
}

Unable to use ec2 cloudwatch logs on windows 2016

I added a \Program Files\Amazon\SSM\Plugins\awsCloudWatch\AWS.EC2.Windows.Cloudwatch.json file as explained to my user-data startup and restarted the ssm service as explained in the documentation for windows 2016. There are no errors in the ssm agent log. However, I do not see AWS.Cloudwatch.exe running, and no logs make it to cloudwatch.
I am really interested in just the application and system event logs and the \programdata\amazon\ecs\log directory. If I get that working, I will add the launch logs too.
Where can I look for clues? I did try starting the aws.cloudwatch.exe manually but don't know what the configuration argument is supposed to look like.
Here is my configuration
$ssmconfig = #"
{
"IsEnabled": true,
"EngineConfiguration": {
"PollInterval": "00:00:05",
"Components": [
{
"Id": "ApplicationEventLog",
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"LogName": "Application",
"Levels": "1"
}
},
{
"Id": "SystemEventLog",
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"LogName": "System",
"Levels": "7"
}
},
{
"Id": "SecurityEventLog",
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"LogName": "Security",
"Levels": "7"
}
},
{
"Id": "CustomLogs",
"FullName": "AWS.EC2.Windows.CloudWatch.CustomLog.CustomLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"LogDirectoryPath": "C:\\ProgramData\\Amazon\ECS\Log
",
"TimestampFormat": "MM/dd/yyyy HH:mm:ss",
"Encoding": "UTF-8",
"Filter": "",
"CultureName": "en-US",
"TimeZoneKind": "Local"
}
},
{
"Id": "CloudWatchLogs",
"FullName": "AWS.EC2.Windows.CloudWatch.CloudWatchLogsOutput,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"Region": "MYREGION}",
"LogGroup": "MYLOGGGROUP/win-host-eventlog",
"LogStream": "THISINSTANCEID"
}
},
{
"Id": "CloudWatchEcsLogs",
"FullName": "AWS.EC2.Windows.CloudWatch.CloudWatchLogsOutput,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"Region": "MYREGION",
"LogGroup": "MYLOGGROUP/win-host-ecs-logs",
"LogStream": "THISINSTANCEID"
}
}
],
"Flows": {
"Flows": [
"(ApplicationEventLog,SystemEventLog),CloudWatchLogs"
"CustomLogs,CloudWatchEcsLogs"
]
}
}
}
"#
Add-Content "C:\Program Files\Amazon\SSM\Plugins\awsCloudWatch\AWS.ECS.Windows.CloudWatch.json" $ssmconfig
Restart-Service AmazonSSMAgent
`
According to the documentation:
The EC2Config service is not included in AWS Windows 2016 AMIs and you need to install it manually. Install it, run it, enable log integration, and update the JSON file (normally) located in the following path:
C:\Program Files\Amazon\SSM\Plugins\awsCloudWatch
Here is the configuration I have on my servers. It works fine and I get both logs and performance metrics.
{
"IsEnabled": true,
"EngineConfiguration": {
"Components": [{
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "ApplicationEventLog",
"Parameters": {
"Levels": "1",
"LogName": "Application"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "SystemEventLog",
"Parameters": {
"Levels": "7",
"LogName": "System"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "SecurityEventLog",
"Parameters": {
"Levels": "7",
"LogName": "Security"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "ETW",
"Parameters": {
"Levels": "7",
"LogName": "Microsoft-Windows-WinINet/Analytic"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.IisLog.IisLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "IISLog",
"Parameters": {
"LogDirectoryPath": "C:\\inetpub\\logs\\LogFiles\\W3SVC1"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.CustomLog.CustomLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "CustomLogs",
"Parameters": {
"CultureName": "en-US",
"Encoding": "UTF-8",
"Filter": "",
"LogDirectoryPath": "C:\\Logs\\",
"TimeZoneKind": "Local",
"TimestampFormat": "yyyy-MM-dd HH:mm:ss"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "PerformanceCounterMemory",
"Parameters": {
"CategoryName": "Memory",
"CounterName": "Available MBytes",
"DimensionName": "InstanceId",
"DimensionValue": "{instance_id}",
"InstanceName": "",
"MetricName": "Memory",
"Unit": "Megabytes"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "PerformanceCounterDisk",
"Parameters": {
"CategoryName": "LogicalDisk",
"CounterName": "Free Megabytes",
"DimensionName": "InstanceId",
"DimensionValue": "{instance_id}",
"InstanceName": "D:",
"MetricName": "FreeDisk",
"Unit": "Megabytes"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.CloudWatchLogsOutput,AWS.EC2.Windows.CloudWatch",
"Id": "CloudWatchLogs",
"Parameters": {
"AccessKey": "",
"LogGroup": "ASG",
"LogStream": "{instance_id}",
"Region": "eu-west-1",
"SecretKey": ""
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.CloudWatch.CloudWatchOutputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "CloudWatch",
"Parameters": {
"AccessKey": "",
"NameSpace": "PerformanceMonitor",
"Region": "eu-west-1",
"SecretKey": ""
}
}],
"Flows": {
"Flows": [
"(PerformanceCounterMemory,PerformanceCounterDisk),CloudWatch",
"(ApplicationEventLog,SystemEventLog),CloudWatchLogs"
]
},
"PollInterval": "00:00:15"
}
}

Resources