# When \`xpack.ml.enabled\` is set to false, entering Kibana's machine learning page has a error in the log

**URL:** <https://discuss.elastic.co/t/when-xpack-ml-enabled-is-set-to-false-entering-kibanas-machine-learning-page-has-a-error-in-the-log/301158>\
**Category:** Kibana\
**Tags:** elastic-stack-machine-learning, docker\
**Created:** [March 31, 2022, 5:39am UTC](https://discuss.elastic.co/t/when-xpack-ml-enabled-is-set-to-false-entering-kibanas-machine-learning-page-has-a-error-in-the-log/301158 "2022-03-31T05:39:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![linghengqian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/linghengqian/32/103651_2.png) [@linghengqian](https://discuss.elastic.co/u/linghengqian)\
**Post date:** [March 31, 2022, 5:39am UTC](https://discuss.elastic.co/t/when-xpack-ml-enabled-is-set-to-false-entering-kibanas-machine-learning-page-has-a-error-in-the-log/301158/1 "2022-03-31T05:39:09Z")

</div>

- I am doing some tests in `docker-compose.yml`, I noticed that when I set the `Elasticsearch` environment variable to contain `XPACK_ML_ENABLED: false`, the `machine learning` page of the `Kibana` instance will jump to some urls like crazy, and the `Kibana` page also has the corresponding log to Show errors.

```nohighlight
[2022-03-31T12:47:10.150+08:00][INFO][plugins.security.routes] Logging in with provider "basic" (basic)
[2022-03-31T12:47:10.946+08:00][INFO][status] Kibana is now available (was degraded)
[2022-03-31T12:55:26.827+08:00][INFO][plugins.fleet] Beginning fleet setup
[2022-03-31T12:55:26.889+08:00][INFO][plugins.fleet] Fleet setup completed
[Error [UnsubscriptionError]: 1 errors occurred during unsubscription:
1) ReferenceError: Cannot access 'sub' before initialization] {
    ReferenceError: Cannot access 'sub' before initialization
  errors: [
        at Subscription.<anonymous> (/usr/share/kibana/src/plugins/bfetch/server/streaming/create_compressed_stream.js:52:5)
        at Subscription.unsubscribe (/usr/share/kibana/node_modules/rxjs/internal/Subscription.js:40:30)
        at FinallySubscriber.Subscription.unsubscribe (/usr/share/kibana/node_modules/rxjs/internal/Subscription.js:53:29)
        at Subscriber.unsubscribe (/usr/share/kibana/node_modules/rxjs/internal/Subscriber.js:86:38)
        at FinallySubscriber.Subscriber.unsubscribe (/usr/share/kibana/node_modules/rxjs/internal/Subscriber.js:86:38)
        at Subscriber.Subscription.unsubscribe (/usr/share/kibana/node_modules/rxjs/internal/Subscription.js:53:29)
        at SafeSubscriber._unsubscribe (/usr/share/kibana/node_modules/rxjs/internal/Subscriber.js:241:27)
        at SafeSubscriber.Subscriber.unsubscribe (/usr/share/kibana/node_modules/rxjs/internal/Subscriber.js:86:38)
        at SafeSubscriber.Subscription.unsubscribe (/usr/share/kibana/node_modules/rxjs/internal/Subscription.js:40:30)
[2022-03-31T12:47:07.897+08:00][INFO][plugins.screenshotting.chromium] Browser executable: /usr/share/kibana/x-pack/plugins/screenshotting/chromium/headless_shell-linux_x64/headless_shell
        at Subscriber.complete (/usr/share/kibana/node_modules/rxjs/internal/Subscriber.js:78:18)
        at SafeSubscriber.complete (/usr/share/kibana/node_modules/rxjs/internal/Subscriber.js:191:26)
        at Subscriber._complete (/usr/share/kibana/node_modules/rxjs/internal/Subscriber.js:96:26)
        at FinallySubscriber.Subscriber._complete (/usr/share/kibana/node_modules/rxjs/internal/Subscriber.js:96:26)
        at FinallySubscriber.Subscriber.complete (/usr/share/kibana/node_modules/rxjs/internal/Subscriber.js:78:18)
        at CatchSubscriber.Subscriber.complete (/usr/share/kibana/node_modules/rxjs/internal/Subscriber.js:78:18)
        at CatchSubscriber.Subscriber._complete (/usr/share/kibana/node_modules/rxjs/internal/Subscriber.js:96:26)
        at MergeMapSubscriber._complete (/usr/share/kibana/node_modules/rxjs/internal/operators/mergeMap.js:88:30)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
        at Observable.subscribe (/usr/share/kibana/node_modules/rxjs/internal/Observable.js:30:22)
        at Observable._subscribe (/usr/share/kibana/node_modules/rxjs/internal/util/subscribeToArray.js:7:16)
        at MergeMapSubscriber.Subscriber.complete (/usr/share/kibana/node_modules/rxjs/internal/Subscriber.js:78:18)
        at Observable._trySubscribe (/usr/share/kibana/node_modules/rxjs/internal/Observable.js:44:25)
        at Observable.subscribe (/usr/share/kibana/node_modules/rxjs/internal/Observable.js:25:31)
        at MergeMapOperator.call (/usr/share/kibana/node_modules/rxjs/internal/operators/mergeMap.js:37:23)
        at CatchOperator.call (/usr/share/kibana/node_modules/rxjs/internal/operators/catchError.js:30:23)
        at FinallyOperator.call (/usr/share/kibana/node_modules/rxjs/internal/operators/finalize.js:27:23)
        at createStream (/usr/share/kibana/src/plugins/bfetch/server/streaming/create_stream.js:20:74)
        at createCompressedStream (/usr/share/kibana/src/plugins/bfetch/server/streaming/create_compressed_stream.js:53:7)
        at /usr/share/kibana/src/plugins/bfetch/server/plugin.js:58:45
        at /usr/share/kibana/src/core/server/context/container/context.js:62:16
        at runMicrotasks (<anonymous>)
        at Router.handle (/usr/share/kibana/src/core/server/http/router/router.js:163:30)
        at exports.Manager.execute (/usr/share/kibana/node_modules/@hapi/hapi/lib/toolkit.js:60:28)
        at exports.execute (/usr/share/kibana/node_modules/@hapi/hapi/lib/handler.js:31:20)
  ]
}
        at Request._execute (/usr/share/kibana/node_modules/@hapi/hapi/lib/request.js:281:9)
        at Request._lifecycle (/usr/share/kibana/node_modules/@hapi/hapi/lib/request.js:371:32)
        at Object.internals.handler (/usr/share/kibana/node_modules/@hapi/hapi/lib/handler.js:46:20)
        at handler (/usr/share/kibana/src/core/server/http/router/router.js:124:50)
[2022-03-31T12:56:57.264+08:00][INFO][plugins.fleet] Fleet setup completed
[2022-03-31T12:56:56.810+08:00][INFO][plugins.fleet] Beginning fleet setup

```

- 

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/3/d373dbc5d4cd1e3d1b7cc794c3870f1c18331eb4.png)

- Also the Elasticsearch instance has a warn, but I'm not sure if it's relevant.

```nohighlight
{"@timestamp":"2022-03-31T04:57:50.880Z", "log.level": "WARN", "data_stream.dataset":"deprecation.elasticsearch","data_stream.namespace":"default","data_stream.type":"logs","elasticsearch.elastic_product_origin":"kibana","elasticsearch.event.category":"api","elasticsearch.http.request.x_opaque_id":"465c0681-cbf7-4ca6-9aab-0c334b9fab85;kibana::management:","event.code":"open_system_index_access","message":"this request accesses system indices: [.async-search, .security-7, .tasks, .transform-internal-007], but in a future major version, direct access to system indices will be prevented by default" , "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"deprecation.elasticsearch","process.thread.name":"elasticsearch[node01.elasticsearch.test.com][transport_worker][T#1]","log.logger":"org.elasticsearch.deprecation.cluster.metadata.IndexNameExpressionResolver","trace.id":"35a2fbeff0bf419a2debf9e82cd6aef7","elasticsearch.cluster.uuid":"-cezmxW7TMKuqZFy_YccFA","elasticsearch.node.id":"9traWmKDSZmC228Ks3JC8A","elasticsearch.node.name":"node01.elasticsearch.test.com","elasticsearch.cluster.name":"test-elasticsearch"}

```

- I think if `Kibana` detects that the setting `XPACK_ML_ENABLED` of the corresponding ElatsicSearch is `false`, would it be better not to display this `machine learning` entry directly? But I'm not sure how to hide it, and now I always get an error when entering this page. At the same time the page flickers.
- ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/9/a9bb2601e337ccc0309bc8da39870d286d6a79a4.png)
- Below is the `docker-compose.yml` I use for testing. After startup, I registered `Kibana` with `ElasticSearch` through the token generated by `bin/elasticsearch-create-enrollment-token -s kibana`.

```nohighlight
version: "3.8"
services:
  elasticsearch-node01:
    image: elasticsearch:8.1.1
    hostname: node01.elasticsearch.test.com
    environment:
      TZ: Asia/Shanghai
      ES_SETTING_BOOTSTRAP_MEMORY__LOCK: true
      ES_SETTING_CLUSTER_NAME: "test-elasticsearch"
      ELASTIC_PASSWORD: "6123AF57-35CA-B2E0-BE8B-12345D5C123E"
      XPACK_ML_ENABLED: false
      ES_JAVA_OPTS: "-Xms4g -Xmx4g"
    volumes:
      - elasticsearch-data01:/usr/share/elasticsearch/data
    ports:
      - "9200:9200"
      - "9300:9300"
    ulimits:
      memlock:
        soft: -1
        hard: -1
  kibana-node01:
    image: kibana:8.1.1
    hostname: node01.kibana.test.com
    environment:
      TZ: Asia/Shanghai
      XPACK_SECURITY_ENCRYPTIONKEY: fc12345ea223eb1234dac7b5678ac62e
      XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY: 1bb12c4e9ed1c36ae4a8ead1234567f1
      XPACK_REPORTING_ENCRYPTIONKEY: af5cbdd2e2f4da20a72f60f1e123450f
      XPACK_REPORTING_ROLES_ENABLED: false
      XPACK_REPORTING_KIBANASERVER_HOSTNAME: localhost
      SERVER_PUBLICBASEURL: http://localhost:5601
      I18N_LOCALE: zh-CN
    ports:
      - "5601:5601"
    volumes:
      - kibana-data01:/usr/share/kibana/data
volumes:
  elasticsearch-data01:
    driver: local
  kibana-data01:
    driver: local

```

---

<div class="post-metadata">

**Author:** ![dolaru](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dolaru/32/55681_2.png) [@dolaru](https://discuss.elastic.co/u/dolaru)\
**Post date:** [March 31, 2022, 9:16am UTC](https://discuss.elastic.co/t/when-xpack-ml-enabled-is-set-to-false-entering-kibanas-machine-learning-page-has-a-error-in-the-log/301158/2 "2022-03-31T09:16:52Z")

</div>

Hi @linghengqian.

> I think if `Kibana` detects that the setting `XPACK_ML_ENABLED` of the corresponding ElatsicSearch is `false` , would it be better not to display this `machine learning` entry directly?

You are correct. Kibana should detect that ML is disabled in Elasticsearch and not show the app in the sidebar.

After setting `XPACK_ML_ENABLED: false` for your Elasticsearch container, did you restart the Kibana container as well?

---

<div class="post-metadata">

**Author:** ![linghengqian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/linghengqian/32/103651_2.png) [@linghengqian](https://discuss.elastic.co/u/linghengqian)\
**Post date:** [March 31, 2022, 10:02am UTC](https://discuss.elastic.co/t/when-xpack-ml-enabled-is-set-to-false-entering-kibanas-machine-learning-page-has-a-error-in-the-log/301158/3 "2022-03-31T10:02:42Z")

</div>

- After restarting `Kibana`, this situation no longer occurs. It seems that the wrong log is caused by the device on my side. But when I enter the `machine learning` page, I still see that it is switching urls like crazy, causing `Chrome`'s address bar to flicker. Until after a while it goes to `localhost:5601/app/ml/datavisualizer`. (Yes, no error or warn log in Kibana )
- ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/f/3f1ef0b5c72cf28700beedb04fb2c9c02dc684ab.png)
- ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/8/585555fb6ad7ededc659966681cbc5a48dd19e2e.png)

---

<div class="post-metadata">

**Author:** ![dolaru](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dolaru/32/55681_2.png) [@dolaru](https://discuss.elastic.co/u/dolaru)\
**Post date:** [March 31, 2022, 5:35pm UTC](https://discuss.elastic.co/t/when-xpack-ml-enabled-is-set-to-false-entering-kibanas-machine-learning-page-has-a-error-in-the-log/301158/4 "2022-03-31T17:35:05Z")

</div>

I tried to reproduce the issue with with a `docker-compose` setup identical to the one mentioned in your first post, but I didn't notice any issues with the URL flickering or any redirect loops when navigating to the Machine Learning page.

Could you please update Chrome to the latest version, clear the cache and let me know if you're still seeing this issue?

Later edit: Is this the flickering you're talking about?  
 ![kbn_url_ml](https://us1.discourse-cdn.com/elastic/original/3X/7/9/79b273014853492fb18470dea85c0103264c0bb8.gif)

If yes, this is normal.

---

<div class="post-metadata">

**Author:** ![linghengqian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/linghengqian/32/103651_2.png) [@linghengqian](https://discuss.elastic.co/u/linghengqian)\
**Post date:** [April 1, 2022, 12:18am UTC](https://discuss.elastic.co/t/when-xpack-ml-enabled-is-set-to-false-entering-kibanas-machine-learning-page-has-a-error-in-the-log/301158/5 "2022-04-01T00:18:43Z")

</div>

- I restarted a new `compose` instance locally and it didn't reproduce. When I restarted the old instance with `docker compose down --volumes` and `docker compose up -d` to restart, the problem disappeared, it seems to be because of the old instance, the `/usr/share/kibana/data` of `kibana` of the instance is damaged.
- thank you very much for your help~

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 29, 2022, 12:18am UTC](https://discuss.elastic.co/t/when-xpack-ml-enabled-is-set-to-false-entering-kibanas-machine-learning-page-has-a-error-in-the-log/301158/6 "2022-04-29T00:18:48Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
