0
votes

I'm trying out Elastic APM. I have successfully created a service with data flowing in. I wanted to see if I can have multiple services. Somehow, I ran into problems, so I wanted to delete some services. However, I couldn't find a way to delete a service.

enter image description here

Question : How can I delete a service in APM?

Further information

Indexes related to APM :

enter image description here

{
  "_index": "apm-7.3.2-metric-000001",
  "_type": "_doc",
  "_id": "XgEhYm0BiAdOXLlDGc-r",
  "_version": 1,
  "_score": null,
  "_source": {
    "jvm": {
      "memory": {
        "non_heap": {
          "committed": 87449600,
          "max": -1,
          "used": 66599704
        },
        "heap": {
          "committed": 232783872,
          "max": 2025848832,
          "used": 170023936
        }
      },
      "thread": {
        "count": 63
      },
      "gc": {
        "alloc": 632406344
      }
    },
    "observer": {
      "hostname": "localhost.localdomain",
      "id": "d1aec10a-cc4e-44f4-9aed-acf57d107ab7",
      "ephemeral_id": "ae48b040-f9f6-4144-a600-d402defaa44a",
      "type": "apm-server",
      "version": "7.3.2",
      "version_major": 7
    },
    "agent": {
      "name": "java",
      "ephemeral_id": "66d5c439-271c-483d-a426-d0e569bede4a",
      "version": "1.9.0"
    },
    "process": {
      "pid": 16154,
      "title": "/usr/lib/jvm/java-11-openjdk-11.0.1.13-3.el7_6.x86_64/bin/java",
      "ppid": 1
    },
    "@timestamp": "2019-09-24T07:16:28.461Z",
    "system": {
      "process": {
        "memory": {
          "size": 6070763520
        },
        "cpu": {
          "total": {
            "norm": {
              "pct": 0.001925814284518128
            }
          }
        }
      },
      "memory": {
        "actual": {
          "free": 749580288
        },
        "total": 8102449152
      },
      "cpu": {
        "total": {
          "norm": {
            "pct": 0.033324960227748474
          }
        }
      }
    },
    "ecs": {
      "version": "1.0.1"
    },
    "service": {
      "name": "ldap1",
      "runtime": {
        "name": "Java",
        "version": "11.0.1"
      },
      "language": {
        "name": "Java",
        "version": "11.0.1"
      }
    },
    "host": {
      "hostname": "localhost.localdomain",
      "os": {
        "platform": "Linux"
      },
      "ip": "127.0.0.1",
      "architecture": "amd64"
    },
    "processor": {
      "name": "metric",
      "event": "metric"
    }
  },
  "fields": {
    "@timestamp": [
      "2019-09-24T07:16:28.461Z"
    ]
  },
  "sort": [
    1569309388461
  ]
}

Above contains the service that I want to remove.

"service": {
      "name": "ldap1",
      "runtime": {
        "name": "Java",
        "version": "11.0.1"
      },
2
Can you tell what "didn't work" means in your case?Val
Can you show a sample document that you think should match? Also can you show the mapping of your apm index?Val
@Val Okay. I'll try to find them. I ran those services with java -jar apm-agent-attach-1.9.0-standalone.jar --pid 16832 --args 'service_name=ldap;server_urls=http://localhost:8200' . I didn't create them with Kibana console . I'll try to find the mapping and others. Wait a sec.Jin Lee
For the doc simply run GET apm*/_search?size=1Val
For the mapping run GET apm* and then simply copy the mapping for the field context.service.nameVal

2 Answers

4
votes

You simply need to change your query to this:

POST apm*/_delete_by_query
{
  "query": {
     "term": {
       "service.name": "ldap1"
     }
  }
}
2
votes

The accepted answer no longer works, you can use the following

POST /apm-*/_delete_by_query
{
  "query": {
"bool": {
  "must": [
    {
      "term": {
        "service.name": {
          "value": "my-application"
        }
      }
    }
  ]
}
  }
}