hm21
September 21, 2023, 8:19pm
1
Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
OpenSearch: 2.9
Dashboard: 2.9
OS: Ubuntu 22.04
Browser: Firefox
Describe the issue :
Adding prometheus as data source to OpenSearch is not possible when
the “prometheus.uri” has a custom TLDs and therefore not being one of the usual TLDs.
I just tried to connect to Prometheus based on the following documentation:
Metrics analytics - OpenSearch documentation
Are there any workarounds?
Gsmitt
September 22, 2023, 4:00am
2
Hey @hm21
I have Prometheus sending data to Opensearch, its pulling metrics from a remote Graylog server.
What I did…
POST _plugins/_query/_datasources
{
"name" : "graylog",
"connector": "prometheus",
"properties" : {
"prometheus.uri" : "http://graylog.domain.com:9091"
}
}
I changed prometheus port number while back.
Had to wait a couple minutes and here is the results.
hm21
September 22, 2023, 9:09am
3
Yea, this works but what if “prometheus.uri” is https://my-prometheus.local or https://my-prometheus.tech or https://my-prometheus.lan .
These don’t work. The Exception comes from the following code:
private static void validateDomain(String uriString) throws URISyntaxException {
URI uri = new URI(uriString);
String host = uri.getHost();
if (host == null
|| (!(DomainValidator.getInstance().isValid(host)
|| DomainValidator.getInstance().isValidLocalTld(host)))) {
throw new IllegalArgumentException(
String.format("Invalid hostname in the uri: %s", uriString));
}
}
You can find the java file here: sql/datasources/src/main/java/org/opensearch/sql/datasources/utils/DatasourceValidationUtils.java at 6ae767cfd222bcf808a2e22c15529641bb75f999 · opensearch-project/sql (github.com)
hm21
September 22, 2023, 10:09am
4
Does anyone know about workarounds to get these kind of uri’s working as prometheus data source?
hm21
September 22, 2023, 1:29pm
5
Also IP-Addresses are not valid.
Gsmitt
September 22, 2023, 9:22pm
6
Hey @hm21
I have a a domain .local (i.e., lab-testing.local) it will work is you have a PTR in your DNS server,If not you can edit you /etc/hosts file. Opensearch needs to find that FQDN.
192.168.1.100 my-prometheus.local my-prometheus.lan
Not sure what you error is when you try those FQDN’s beside what you post above.
hm21
September 23, 2023, 9:39am
7
So I need to edit the /etc/hosts file on the OpenSearch host?
hm21
September 24, 2023, 11:38am
8
Did you also try a domain with .lan TLD? And I don’t really get why a PTR is needed. For a domain with .com TLD a PTR is also not needed, right?
Gsmitt
September 25, 2023, 9:58pm
9
Hey @hm21
Simply put, Opensearch needs to find where my-prometheus.local is located.
So somewhere you need to tell Opensearch where my-prometheus.local = <some_ip_address>
Edit: TLDs that aren’t sanctioned or recognized by ICANN and only exist on their own private root DNS servers.
hm21
October 7, 2023, 3:04pm
10
It doesn’t work when OpenSearch is deployed in docker containers
hm21
October 8, 2023, 10:28am
11
I just added my-prometheus.an to /etc/hosts file on the host machine and not the opensearch container but it still won’t work.
hm21
October 9, 2023, 7:54am
12
Would you like to try it out in a container?
Gsmitt
October 10, 2023, 4:47am
13
Hey @hm21
No im good with containers, perhaps someone else here has.
hm21
October 10, 2023, 9:28am
14
Why are you good with containers? xD
Gsmitt
October 11, 2023, 9:01pm
15
@hm21
Appologies, I meant to say Im not good.
hm21
October 11, 2023, 9:53pm
16
oh, okay. dont worry. i will come back when i have the solution for the problem!