Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for url_prefix in elastisearch source #4214

Merged
merged 3 commits into from
Feb 25, 2022

Conversation

pppsunil
Copy link
Contributor

@pppsunil pppsunil commented Feb 22, 2022

There are cases where an enterprise would have multiple elastic search clusters. One way for them to manage is to have a single endpoint for all the elastic search clusters and use url_prefix for routing requests to different clusters.

The current elasticsearch source does not support this use case. We can add the support by adding an optional config parameter called url_prefix and passing the value of url_prefix to the underlying Elasticsearch client constructor while creating it like

source:
  type: "elasticsearch"
  config:
    env: "DEV"
    host: "localhost:9200"
    url_prefix: 'test_cluste1'

We need one more change to support this. Right now we use the following call for getting the list of indices from elastisearch es.indices.get_alias(index="*") which results into HTTP call like http://localhost:29200 "GET /test_cluster1/*

es.indices.get_alias(index="*")
DEBUG:urllib3.connectionpool:http://localhost:29200 "GET /test_cluster1/*/_alias HTTP/1.1" 403 93
WARNING:elasticsearch:GET http://localhost:29200/test_cluster1/*/_alias [status:403 request:0.003s]
DEBUG:elasticsearch:> None
DEBUG:elasticsearch:< <html><body><h1>403 Forbidden</h1>
Request forbidden by administrative rules.
</body></html>

In cases where you have multiple elasticsearch clusters along with ACL on them, the call would get blocked, rejected.

Another way to get a list of indices would be es.indices.get_alias()

es.indices.get_alias()
DEBUG:urllib3.connectionpool:http://localhost:29200 "GET /test_cluster1/_alias HTTP/1.1" 200 39430
INFO:elasticsearch:GET http://localhost:29200/test_cluster1/_alias [status:200 request:0.008s]
DEBUG:elasticsearch:> None
DEBUG:elasticsearch:< 

This should return the list in the same way

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable)

@pppsunil pppsunil changed the title Elasticsearch url prefix Add support for url_prefix in elastisearch source Feb 22, 2022
@github-actions
Copy link

github-actions bot commented Feb 22, 2022

Unit Test Results (build & test)

  69 files   -   1    69 suites   - 1   8m 48s ⏱️ - 4m 53s
540 tests  - 71  488 ✔️  - 64  52 💤  - 7  0 ±0 

Results for commit 07895d8. ± Comparison against base commit c6cb549.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 22, 2022

Unit Test Results (metadata ingestion)

       5 files  ±  0         5 suites  ±0   44m 54s ⏱️ + 1m 30s
   332 tests  -   9     332 ✔️  -   9    0 💤 ±0  0 ±0 
1 507 runs   - 45  1 469 ✔️  - 52  38 💤 +7  0 ±0 

Results for commit 07895d8. ± Comparison against base commit c6cb549.

This pull request removes 15 and adds 6 tests. Note that renamed tests count towards both.
tests.unit.test_mce_builder ‑ test_make_dataset_urns[athena]
tests.unit.test_mce_builder ‑ test_make_dataset_urns[bigquery]
tests.unit.test_mce_builder ‑ test_make_dataset_urns[bigquery_no_instance]
tests.unit.test_mce_builder ‑ test_make_dataset_urns[druid]
tests.unit.test_mce_builder ‑ test_make_dataset_urns[hive]
tests.unit.test_mce_builder ‑ test_make_dataset_urns[kafka_no_instance_no_lower_casing]
tests.unit.test_mce_builder ‑ test_make_dataset_urns[kafka_no_lower_casing]
tests.unit.test_mce_builder ‑ test_make_dataset_urns[mariadb]
tests.unit.test_mce_builder ‑ test_make_dataset_urns[mssql]
tests.unit.test_mce_builder ‑ test_make_dataset_urns[mysql]
…
tests.unit.serde.test_serde ‑ test_type_error
tests.unit.test_dataset_urn.TestDatasetUrn ‑ test_invalid_urn
tests.unit.test_dataset_urn.TestDatasetUrn ‑ test_parse_urn
tests.unit.test_kafka_source.KafkaSourceTest ‑ test_kafka_source_workunits_schema_registry_subject_name_strategies
tests.unit.test_urn.TestUrn ‑ test_invalid_urn
tests.unit.test_urn.TestUrn ‑ test_parse_urn

♻️ This comment has been updated with latest results.

Copy link
Contributor

@shirshanka shirshanka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@shirshanka shirshanka merged commit 16f3d46 into datahub-project:master Feb 25, 2022
maggiehays pushed a commit to maggiehays/datahub that referenced this pull request Aug 1, 2022
…tion (datahub-project#4214)

Co-authored-by: Sunil Patil <spatil@twilio.com>
Co-authored-by: Shirshanka Das <shirshanka@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants