json - Exporting MobileFirst Analytics data -
i've captured event logs mobilefirst 7.1 client app (hybrid ios) using analytics api:
wl.analytics.log({'module': 'account', 'activity': 'update account'}, 'message title');
and retrieve logs analytics console without problem.
next retrieve logs using analytics api. below working url format:
http://localhost:10080/analytics-service/data/administration/apps/worklight/export?query={"event":"customdata","format":"json","limit":10,"offset":0,"startdate":"2016-08-24","enddate":"*"}
which returns following json data:
[ { "mfpappname": "myapp", "deviceos": "ios", "appid": "worklight", "mfpappversion": "1.0", "deviceosversion": "7", "devicemodel": "xxx", "deviceid": "xxx", "timestamp": "1472038253030", "module": "account", "activity": "update account" } ]
my questions:
- how can filter json results based on custom data? example, want retrieve logs activities have value: "module": "account" only.
- how can sort json results, example, based on timestamp value?
when tried add in own parameter(e.g. "filter") url, return error says:
{"err":"unrecognized field \"filter\" (class com.ibm.mobile.analytics.server.rest.params.exportparameters), not marked ignorable (29 known properties: , \"level\", \"validationcode\", \"serveripaddress\", \"mfpappversion\", \"hours\", \"realm\", \"adapter\", \"debug\", \"offset\", \"mfpappname\", \"event\", \"deviceosversion\", \"timestampkey\", \"enddate\" [truncated]])\n @ [source: java.io.stringreader@4c3deb33; line: 1, column: 33] (through reference chain: com.ibm.mobile.analytics.server.rest.params.exportparameters[\"search\"])"}
may know can find "29 known properties" mentions?
i learned mfp analytics using elasticsearch engine , tried find info no avail.
to achieve goal going have enable elasticsearch rest endpoint. if on liberty server simple, use jndi properties below.
<jndientry jndiname="analytics/http.enabled" value="true"/> <jndientry jndiname="analytics/httpport" value="9500"/>
after enabling elasticsearch rest endpoint can write custom queries against backend.
you can write post request similar 1 below:
curl 'http://localhost:9500/worklight/_search?sort=timestamp:asc' -d '{"query" : {"wildcard":{"worklight_data.module": {"value": "account"}}}}'
some elasticsearch references may find useful: https://www.elastic.co/guide/en/elasticsearch/reference/2.1/search-uri-request.html https://www.elastic.co/guide/en/elasticsearch/reference/2.1/search-request-body.html
Comments
Post a Comment