Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metrics data is always 0 #7

Open
konraddysput opened this issue Aug 1, 2019 · 4 comments
Open

Metrics data is always 0 #7

konraddysput opened this issue Aug 1, 2019 · 4 comments

Comments

@konraddysput
Copy link

Hey!

Yesterday I tried to integrate my node application by using circonous-cip npm package and trap method. This is how my code looks like:

import * as circonus_cip from 'circonus-cip';
import * as express from 'express';
import { Logger } from '../logger/logger';
import { IMetricsOptions } from './configuration';
export class MetricsStorage {
  private readonly trap = circonus_cip.makeTrap(
    this._opts.uuid,
    this._opts.secret,
  );

  constructor(app: express.Express, private readonly _opts: IMetricsOptions) {
    if (!this._opts.secret || !this._opts.uuid) {
      Logger.getLogger().warn(
        `Metrics are disabled - undefined secret or uuid`,
      );
      return;
    }
    app.use(circonus_cip.express(this._opts.uuid, this._opts.secret));
  }
  public addMetric(name: string, value: number | string | boolean) {
    this.trap.record(name, value);
  }
}

The main issue that I have with this code is:

  • I can create new metrics chart when I change metrics name which is fine
  • data in each chart is always 0.

To detect problem with 0 value I used new Date().getTime() value to always have different big value. Example code:

service.metrics.addMetric('sample', new Date().getTime());

Am I doing something wrong? It seems like package contains all necessary data but circonous anyway display 0 on each chart :(

Thanks!

@maier
Copy link
Member

maier commented Aug 1, 2019

Look at your check bundle in the UI. If the submission URL has a host of api.circonus.com, set the opts.broker option to that and in the calls to circonus_cip.makeTrap and circonus_cip.express.

@amadden80
Copy link

I just hit the same issue myself. I believe the issue has to do with how the _value is being formatted. For example, if we pass the value 5, it gets formatted to something like H(5e0)=1. If I hard code this value in the node_modules to just send _value as 5, Circonous does recognize the value as 5. Maybe the expectations for _value have changed since this package was updated?

@konraddysput
Copy link
Author

hi @maier
thanks for your suggestions, but I still cannot push any data to circonous :(

Anyway if I will use wrong broker, I should be able to create new metrics chart ?

@maier
Copy link
Member

maier commented Aug 2, 2019

@amadden80 the first format is for histograms, sending just a number is a numeric. If you are manually enabling the metrics on in your check ensure you are setting them to be histograms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants