RUM JS not collecting user agent location

This is my 3rd time configuring elastic APM, and always face a problem populating the "Page load distribution" over countries. By default elastic uses geoip processor to add client location for rum data but it's not the case for me. There is no index called traces-apm.rum-default created for RUM data.

Checking https://demo.elastic.co User experience dashboard indeed have the dashboard populated with data and the traces-apm.rum-default index exists.

I configured RUM for a Django application, I added to the base template the following:

<script src="{% static 'js/elastic-rum-based-umd-5.12.js' %}">

</script>
  <script type="text/javascript">
    elasticApm.init({
    serviceName: "frontend_dev_app",
    serverUrl: "http://localhost:8200",
    distributedTracingOrigins: ["http://localhost:8000", "http://127.0.0.1:8000", "http://localhost:8200"],
    pageLoadTraceId: "{{ apm.trace_id }}",
    pageLoadSpanId: "{{ apm.span_id }}",
    pageLoadSampled: {{ apm.is_sampled_js }}
  })
// some code...
    </script>

I am using elastic 7.15.
What am I missing? I checked the doc for rum many times but could not find how to include user agent location for rum data, and could not figure out why I don't have an index like traces-apm.rum-default?

The error I'm having:

Thanks.

Hi @marone,

Thanks for reaching out and apologies for the delay.

RUM doesn't handle anything related to ip address and geo information. That is something that APM server handles. That's why you were not finding information on the RUM documentation.

--

Please, being in the devtools console page execute the following query:

GET /_ingest/geoip/stats

If the output you are getting is something like this:

Screenshot 2022-08-02 at 16.54.06

It means that there has been some issue while downloading the geoip database. So, what you need to do is to "turn it off and on again" the geo pipeline which will force the download of the geoip database

How to turn it off:

PUT /_cluster/settings?pretty
{
  "persistent" : {
    "ingest.geoip.downloader.enabled" : false
  }
}

How to turn it on:

PUT /_cluster/settings?pretty
{
  "persistent" : {
    "ingest.geoip.downloader.enabled" : true
  }
}

After turning it on you will see Elasticsearch logs like this ones:

If you execute the query GET /_ingest/geoip/stats again you will see that now the database has been downloaded properly:

After doing this, if you want to get rid of the "unable to perform term join" issue, what you need to do is to visit your webpage to generate new events, then the User Experience Page will show the data properly, for instance:

Thanks,
Alberto

2 Likes

Thank you so much @Alberto_Delgado for the precise answer. When doing the steps you described indeed I didn't find the geoip database, once I turn it off/on it is downloaded, and didn't get any geo data after, I believe because I tested it on localhost right? I need to deploy it ASAP and get back toyou if needed :smile:.

Marwane.