Skip to content

Commit

Permalink
[PLAT-15621] Make sure scrape interval is used for DB node alive stat…
Browse files Browse the repository at this point in the history
…us query

Summary:
Currently we have range hardcoded to 30 seconds for DB node processes alive query.
This does not work in case we want to increase scrape interval.
Fixing it.

Test Plan:
Increase scrape interval to 30 seconds.
Create universe. Make sure alive status is shown correctly.

Reviewers: vbansal, skurapati, #yba-api-review!

Reviewed By: vbansal, skurapati

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D38764
  • Loading branch information
anmalysh-yb committed Oct 8, 2024
1 parent 3884cc9 commit 94a195b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

package com.yugabyte.yw.controllers.handlers;

import static com.yugabyte.yw.common.SwamperHelper.getScrapeIntervalSeconds;
import static play.mvc.Http.Status.BAD_REQUEST;
import static play.mvc.Http.Status.INTERNAL_SERVER_ERROR;
import static play.mvc.Http.Status.NOT_FOUND;
Expand Down Expand Up @@ -282,12 +283,15 @@ public Path downloadNodeFile(
private JsonNode getUniverseAliveStatus(Universe universe, MetricQueryHelper metricQueryHelper) {
List<MetricQueryResponse.Entry> values = new ArrayList<>();
boolean queryError = false;
long scrapeInterval = getScrapeIntervalSeconds(runtimeConfigFactory.staticApplicationConf());
try {
values =
metricQueryHelper.queryDirect(
"max_over_time(up{node_prefix=\""
+ universe.getUniverseDetails().nodePrefix
+ "\"}[30s])");
+ "\"}["
+ (scrapeInterval * 2)
+ "s])");
} catch (RuntimeException re) {
queryError = true;
log.debug(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ protected Application provideApplication() {
mockReleasesUtils = mock(ReleasesUtils.class);
mockGFlagsValidation = mock(GFlagsValidation.class);

when(mockRuntimeConfig.getString("yb.metrics.scrape_interval")).thenReturn("10s");
when(mockRuntimeConfig.getBoolean("yb.cloud.enabled")).thenReturn(false);
when(mockRuntimeConfig.getBoolean("yb.security.use_oauth")).thenReturn(false);
when(mockRuntimeConfig.getInt("yb.fs_stateless.max_files_count_persist")).thenReturn(100);
Expand Down

0 comments on commit 94a195b

Please sign in to comment.