npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

prometheus-kafka-connect

v1.4.0

Published

kafka-connect connector for prometheus

Downloads

18

Readme

prometheus-kafka-connect

Connector to prometheus client which only includes sink. This will be useful to stream data from Kafka to Prometheus and subsequently to Grafana. This connector depends on, kafka-connect and node-sinek as the consumer. Please read up those dependencies to make things clearer.

You can use javascript consumer or native which depends on librdkafka. The example can be found in example directory, which there is a comment to specify where you need to do the transformation. Basically, you need to do that in ETL function, that needs to be passed to the connector. Or just like the following.

const { runSinkConnector, ConverterFactory } = require("prometheus-kafka-connect");
const config = require("./config.js");

console.log("Waiting for message to be consumed...");

const etl = (message, next) => {

  // Do the transformation here
  let record;
  try {
    record = {
      metric: message.name
      value: 1,
      type: "counter" // or "gauge"
    };
  } catch(err) {
    // Do nothing
  }

  if (record && record.metric && record.value) {
    // Continue with the transformed record
    return next(null, record);
  }

  // Continue without throwing error
  return next();

}

const converter = ConverterFactory.createSinkSchemaConverter(null,etl);

runSinkConnector(config, [converter], console.log.bind(console)).then(sink => {

});

Configuration

  • For the native and non-native consumer please take a look at node-sinek project.
  • There is an example of doing local setup complete with kafka, zookeeper, prometheus, and grafana in local-setup directory
  • Please take a look at example/config.js file, this is an excerpt from there.
...
    connector: {
        options: {
            job: "promclient_job",
            additionalLabels: ["method"]
        },
    },
...

job

This is to mark the job that needed to be consumed by prometheus, the configuration from prometheus is defined in the prometheus.yml, take a look at local-setup directory

additionalLabels

The additionalLabels that are needed for the metric, the default is label, but you can add as many as you want in the array format.