Java Code Examples for io.prometheus.client.CollectorRegistry#defaultRegistry()

The following examples show how to use io.prometheus.client.CollectorRegistry#defaultRegistry() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PushDemo.java    From sofa-lookout with Apache License 2.0 6 votes vote down vote up
static void executeBatchJob() throws Exception {
    CollectorRegistry registry = CollectorRegistry.defaultRegistry;
    Counter requests = Counter.build()
            .name("my_library_requests_total").help("Total requests.")
            .labelNames("method").register();
    requests.labels("get").inc();


    PushGateway pushgateway = new PushGateway("127.0.0.1:7200/prom");
    // pushgateway.setConnectionFactory(new BasicAuthHttpConnectionFactory("my_user", "my_password"));
    Map<String, String> groupingkeys = new HashMap<>();
    groupingkeys.put("app", "xx");
    pushgateway.pushAdd(registry, "my_batch_job", groupingkeys);
    //  pushgateway.pushAdd(registry, "my_batch_job");
}
 
Example 2
Source File: JavaAgent.java    From jmx_exporter with Apache License 2.0 6 votes vote down vote up
public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception {
    // Bind to all interfaces by default (this includes IPv6).
    String host = "0.0.0.0";

    try {
        Config config = parseConfig(agentArgument, host);

        new BuildInfoCollector().register();
        new JmxCollector(new File(config.file)).register();
        DefaultExports.initialize();
        server = new HTTPServer(config.socket, CollectorRegistry.defaultRegistry, true);
    }
    catch (IllegalArgumentException e) {
        System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<port>:<yaml configuration file> " + e.getMessage());
        System.exit(1);
    }
}
 
Example 3
Source File: DMNResultMetricsBuilderTest.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setUp() {
    registry = CollectorRegistry.defaultRegistry;
}
 
Example 4
Source File: MonitoringModule.java    From curiostack with MIT License 5 votes vote down vote up
@Provides
@Singleton
static CollectorRegistry collectorRegistry() {
  CollectorRegistry registry = CollectorRegistry.defaultRegistry;
  DefaultExports.initialize();
  configureLogMetrics();
  return registry;
}
 
Example 5
Source File: MetricCollectorImpl.java    From prom-bitbucket-exporter with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public MetricCollectorImpl(
        LicenseService licenseService,
        ScheduledMetricEvaluator scheduledMetricEvaluator,
        MailService mailService,
        RepositoriesMonitor repositoriesMonitor) {
    this.licenseService = licenseService;
    this.scheduledMetricEvaluator = scheduledMetricEvaluator;
    this.registry = CollectorRegistry.defaultRegistry;
    this.mailService = mailService;
    this.repositoriesMonitor = repositoriesMonitor;
}
 
Example 6
Source File: SpringBootMetricsCollectorTest.java    From client_java with Apache License 2.0 5 votes vote down vote up
@Test
public void collect() throws Exception {
  counterService.increment("foo");
  gaugeService.submit("bar", 3.14);

  CollectorRegistry defaultRegistry = CollectorRegistry.defaultRegistry;
  assertThat(defaultRegistry.getSampleValue("counter_foo"), is(1.0));
  assertThat(defaultRegistry.getSampleValue("gauge_bar"), is(3.14));
}
 
Example 7
Source File: MockedAppInstanceScannerEndpointSpringApplication.java    From promregator with Apache License 2.0 4 votes vote down vote up
@Bean
public CollectorRegistry collectorRegistry() {
	return CollectorRegistry.defaultRegistry;
}
 
Example 8
Source File: HTTPServer.java    From client_java with Apache License 2.0 4 votes vote down vote up
/**
 * Start a HTTP server serving the default Prometheus registry.
 */
public HTTPServer(int port, boolean daemon) throws IOException {
    this(new InetSocketAddress(port), CollectorRegistry.defaultRegistry, daemon);
}
 
Example 9
Source File: HTTPServer.java    From client_java with Apache License 2.0 4 votes vote down vote up
/**
 * Start a HTTP server serving the default Prometheus registry.
 */
public HTTPServer(String host, int port, boolean daemon) throws IOException {
    this(new InetSocketAddress(host, port), CollectorRegistry.defaultRegistry, daemon);
}
 
Example 10
Source File: HTTPServer.java    From client_java with Apache License 2.0 4 votes vote down vote up
/**
 * Start a HTTP server serving the default Prometheus registry using non-daemon threads.
 */
public HTTPServer(String host, int port) throws IOException {
    this(new InetSocketAddress(host, port), CollectorRegistry.defaultRegistry, false);
}
 
Example 11
Source File: PrometheusHandler.java    From light-4j with Apache License 2.0 4 votes vote down vote up
public PrometheusHandler() {
    registry=  CollectorRegistry.defaultRegistry;
}
 
Example 12
Source File: HTTPServer.java    From Mycat2 with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Start a HTTP server serving the default Prometheus registry.
 */
public HTTPServer(int port, boolean daemon) throws IOException {
    this(new InetSocketAddress(port), CollectorRegistry.defaultRegistry, daemon);
}
 
Example 13
Source File: AbstractPrometheusCollectorRegistry.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Before
public void setupCollectorRegistry() {
    this.collectorRegistry = CollectorRegistry.defaultRegistry;
}
 
Example 14
Source File: MockedMetricsEndpointSpringApplication.java    From promregator with Apache License 2.0 4 votes vote down vote up
@Bean
public CollectorRegistry collectorRegistry() {
	return CollectorRegistry.defaultRegistry;
}
 
Example 15
Source File: NoTargetsConfiguredSpringApplication.java    From promregator with Apache License 2.0 4 votes vote down vote up
@Bean
public CollectorRegistry collectorRegistry() {
	return CollectorRegistry.defaultRegistry;
}
 
Example 16
Source File: LabelEnrichmentMockedMetricsEndpointSpringApplication.java    From promregator with Apache License 2.0 4 votes vote down vote up
@Bean
public CollectorRegistry collectorRegistry() {
	return CollectorRegistry.defaultRegistry;
}
 
Example 17
Source File: PrometheusEndpointConfiguration.java    From client_java with Apache License 2.0 4 votes vote down vote up
@Bean
public PrometheusEndpoint prometheusEndpoint() {
  return new PrometheusEndpoint(CollectorRegistry.defaultRegistry);
}
 
Example 18
Source File: MetricsServlet.java    From client_java with Apache License 2.0 4 votes vote down vote up
/**
 * Construct a MetricsServlet for the default registry.
 */
public MetricsServlet() {
  this(CollectorRegistry.defaultRegistry);
}
 
Example 19
Source File: MetricsHttpServer.java    From dts with Apache License 2.0 4 votes vote down vote up
public MetricsHttpServer(String host, int port) throws IOException {
    this(new InetSocketAddress(host, port), CollectorRegistry.defaultRegistry, false);
}
 
Example 20
Source File: MetricsHttpServer.java    From dts with Apache License 2.0 4 votes vote down vote up
public MetricsHttpServer(String host, int port, boolean daemon) throws IOException {
    this(new InetSocketAddress(host, port), CollectorRegistry.defaultRegistry, daemon);
}