user2449016
user2449016

Reputation: 169

How to remove analytics logs in mobilefirst 6.3

We are working in a mobilefirst 6.3 project, and our .war is installed in a liberty profile server.

We didn't configure the TTL on the analytics before. is there any way (tool, rest service or file-system) that I can remove the analytics logs in mobilefirst.

Upvotes: 2

Views: 694

Answers (1)

Idan Adar
Idan Adar

Reputation: 44516

MobileFirst Platform Foundation Analytics uses ElasticSearch and Lucene at its core - there is nothing special to be done from a MobileFirst perspective.

If you want to remove everything, the whole Analytics store:

  1. Stop the Analytics server
  2. Delete the "analyticsData" folder which is under servers/<server-name>/ in the Liberty installation
  3. Restart the server



Otherwise, using either CURL or Postman you can invoke the DELETE query.
You can find the ElasticSearch API here: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html

Some additional questions about this topic in Stack Overflow:

Example steps:

  1. Open the ES port - MobileFirst uses port 9500,
  2. In the Analytics server set the JNDI property http.enabled=true and restart the Analytics server (if it's a cluster, you still only need to open the port on one of the cluster members)
  3. The default "index" to use in your query is "worklight", and the mappings are documented in the user documentation, and are shown on the admin tab in the Analytics console
  4. The endpoint for your delete query would need to be the Analytics server

Postman example query:

DELETE
http://your-analytics-server:9500/worklight/network_transactions/_query
{
  "query": {
    "range": {
      "worklight_data.timestamp": {
        "to": 1432313605000
      }
    }
  }
} 

CURL example query:

curl -X DELETE 'http://server:9500/worklight/network_transactions/_query' (http://server:9500/worklight/network_transactions/_query%27)  -d '{ "query" : { "range" : { "timestamp" : { "lte" : "1432222333424" } } } }' 

Upvotes: 3

Related Questions