use of org.cloudfoundry.promregator.auth.AuthenticationEnricher in project promregator by promregator.
the class AbstractMetricsEndpoint method createMetricsFetchers.
protected List<MetricsFetcher> createMetricsFetchers(List<Instance> instanceList) {
List<MetricsFetcher> callablesList = new LinkedList<>();
for (Instance instance : instanceList) {
log.debug(String.format("Creating Metrics Fetcher for instance %s", instance.getInstanceId()));
ResolvedTarget target = instance.getTarget();
String orgName = target.getOrgName();
String spaceName = target.getSpaceName();
String appName = target.getApplicationName();
String accessURL = instance.getAccessUrl();
if (accessURL == null) {
log.warn(String.format("Unable to retrieve hostname for %s/%s/%s; skipping", orgName, spaceName, appName));
continue;
}
String[] ownTelemetryLabelValues = this.determineOwnTelemetryLabelValues(orgName, spaceName, appName, instance.getInstanceId());
MetricsFetcherMetrics mfm = new MetricsFetcherMetrics(ownTelemetryLabelValues, this.recordRequestLatency);
final boolean labelEnrichmentEnabled = this.isLabelEnrichmentEnabled();
/*
* Warning! the gauge "up" is a very special beast!
* As it is always transferred along the other metrics (it's not a promregator-own metric!), it must always
* follow the same labels as the other metrics which are scraped
*/
Gauge.Child upChild = null;
AbstractMetricFamilySamplesEnricher mfse = null;
if (labelEnrichmentEnabled) {
mfse = new CFAllLabelsMetricFamilySamplesEnricher(orgName, spaceName, appName, instance.getInstanceId());
} else {
mfse = new NullMetricFamilySamplesEnricher();
}
upChild = this.up.labels(mfse.getEnrichedLabelValues(new LinkedList<>()).toArray(new String[0]));
AuthenticationEnricher ae = this.authenticatorController.getAuthenticationEnricherByTarget(instance.getTarget().getOriginalTarget());
MetricsFetcher mf = null;
if (this.simulationMode) {
mf = new MetricsFetcherSimulator(accessURL, ae, mfse, mfm, upChild);
} else {
CFMetricsFetcherConfig cfmfConfig = new CFMetricsFetcherConfig();
cfmfConfig.setAuthenticationEnricher(ae);
cfmfConfig.setMetricFamilySamplesEnricher(mfse);
cfmfConfig.setMetricsFetcherMetrics(mfm);
cfmfConfig.setUpChild(upChild);
cfmfConfig.setPromregatorInstanceIdentifier(this.promregatorInstanceIdentifier);
cfmfConfig.setConnectionTimeoutInMillis(this.fetcherConnectionTimeout);
cfmfConfig.setSocketReadTimeoutInMillis(this.fetcherSocketReadTimeout);
this.provideProxyConfiguration(cfmfConfig);
mf = new CFMetricsFetcher(accessURL, instance.getInstanceId(), cfmfConfig, instance.isInternal());
}
callablesList.add(mf);
}
return callablesList;
}
use of org.cloudfoundry.promregator.auth.AuthenticationEnricher in project promregator by promregator.
the class PromregatorApplication method authenticationEnricher.
@Bean
public AuthenticationEnricher authenticationEnricher(PromregatorConfiguration promregatorConfiguration) {
AuthenticationEnricher ae = null;
String type = promregatorConfiguration.getAuthenticator().getType();
if ("OAuth2XSUAA".equalsIgnoreCase(type)) {
ae = new OAuth2XSUAAEnricher(promregatorConfiguration.getAuthenticator().getOauth2xsuaa());
} else if ("none".equalsIgnoreCase(type) || "null".equalsIgnoreCase(type)) {
ae = new NullEnricher();
} else if ("basic".equalsIgnoreCase(type)) {
ae = new BasicAuthenticationEnricher(promregatorConfiguration.getAuthenticator().getBasic());
} else {
log.warn(String.format("Authenticator type %s is unknown; skipping", type));
}
return ae;
}
Aggregations