Skip to content

Commit 15b2c78

Browse files
committed
Fix issue connecting with prometheus by wrapping with AccessController.doPrivilegedChecked
Signed-off-by: Craig Perkins <cwperx@amazon.com>
1 parent 65baa2a commit 15b2c78

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

direct-query-core/src/main/java/org/opensearch/sql/prometheus/client/PrometheusClientImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.json.JSONArray;
2727
import org.json.JSONException;
2828
import org.json.JSONObject;
29+
import org.opensearch.secure_sm.AccessController;
2930
import org.opensearch.sql.prometheus.exception.PrometheusClientException;
3031
import org.opensearch.sql.prometheus.model.MetricMetadata;
3132

@@ -175,7 +176,7 @@ public Map<String, List<MetricMetadata>> getAllMetrics(Map<String, String> query
175176
"%s/api/v1/metadata%s", prometheusUri.toString().replaceAll("/$", ""), queryString);
176177
logger.debug("queryUrl: " + queryUrl);
177178
Request request = new Request.Builder().url(queryUrl).build();
178-
Response response = this.prometheusHttpClient.newCall(request).execute();
179+
Response response = AccessController.doPrivilegedChecked(() -> this.prometheusHttpClient.newCall(request).execute());
179180
JSONObject jsonObject = readResponse(response);
180181
TypeReference<HashMap<String, List<MetricMetadata>>> typeRef = new TypeReference<>() {};
181182
return new ObjectMapper().readValue(jsonObject.getJSONObject("data").toString(), typeRef);

0 commit comments

Comments
 (0)