GithubHelp home page GithubHelp logo

Comments (11)

moteus avatar moteus commented on June 29, 2024

I can suggest you use different statsd library. Because this library return function
Try figureout which one file loaded by local Statsd = require "statsd" and checkout source.
I use this library without any issues to collect system info from ~10 servers.

from lua-statsd-client.

ramamoob avatar ramamoob commented on June 29, 2024

Thanks for your response. Can you please let me know how you are instantiating the statsd object and calling its methods in your code.

from lua-statsd-client.

moteus avatar moteus commented on June 29, 2024

I think this is almost complite example. I run it as service.

from lua-statsd-client.

ramamoob avatar ramamoob commented on June 29, 2024

Thanks for your example. I am still running into the same issue. I followed your guidance as shown in your example. Below is my code snippet.

local CONFIG = {

      STATSD = {
        NAMESPACE = "test.stats";
        HOST = "127.0.0.1";
        PORT = "8125";
        SEND_TABLE = false;
     };
  };

local Statsd = assert(require "statsd"
  {
      host= CONFIG.STATSD.HOST;
      port = CONFIG.STATSD.PORT;
      namespace = CONFIG.STATSD.NAMESPACE;
  })

  Statsd:increment(message["status"], 1)

During runtime I get this error where I am trying to create the local variable "Statsd".

 attempt to call a table value

Do you know what I am doing wrong?

from lua-statsd-client.

moteus avatar moteus commented on June 29, 2024

You use differen library i think

from lua-statsd-client.

ramamoob avatar ramamoob commented on June 29, 2024

This is the library I am running.

statsd 3.0.2-1 - Statsd client.

Statsd client for Lua 5.1+. Uses the luasocket library for UDP.

License:        MIT/X11
Homepage:       https://github.com/stvp/lua-statsd-client
Installed in:   /usr/local

Modules:
        statsd (/usr/local/share/lua/5.1/statsd.lua)

Depends on:
        luasocket

from lua-statsd-client.

moteus avatar moteus commented on June 29, 2024
  1. try find out what table contain. e.g. print all key/values
    for k,v in pairs(statsd) do print(k,v) end
  2. try find all statusd.lua files and findout which one loaded when you call require.
    (it also can be .so/.dll)
    Contains of statsd can help in this.
    search in directories which you have in package.path/cpath

from lua-statsd-client.

ramamoob avatar ramamoob commented on June 29, 2024

I checked what is in the table. I am printing the key and the type of the value. The output here is from just require 'statsd'.

2015/10/23 19:47:20 [error] 20884#0: [lua] log.lua:38: Type of statsd: table, context: ngx.timer, client: X.X.X.X, server: 0.0.0.0:8000
2015/10/23 19:47:20 [error] 20884#0: [lua] log.lua:39: incr - function, context: ngx.timer, client: X.X.X.X, server: 0.0.0.0:8000
2015/10/23 19:47:20 [error] 20884#0: [lua] log.lua:39: flush - function, context: ngx.timer, client: X.X.X.X, server: 0.0.0.0:8000
2015/10/23 19:47:20 [error] 20884#0: [lua] log.lua:39: buffer - table, context: ngx.timer, client: X.X.X.X, server: 0.0.0.0:8000
2015/10/23 19:47:20 [error] 20884#0: [lua] log.lua:39: count - function, context: ngx.timer, client: X.X.X.X, server: 0.0.0.0:8000
2015/10/23 19:47:20 [error] 20884#0: [lua] log.lua:39: register - function, context: ngx.timer, client: X.X.X.X, server: 0.0.0.0:8000
2015/10/23 19:47:20 [error] 20884#0: [lua] log.lua:39: time - function, context: ngx.timer, client: X.X.X.X, server: 0.0.0.0:8000

I also see that the statsd.lua is loaded from the location

/usr/local/share/lua/5.1/statsd.lua

It is the exact same code as the one in this repo.

from lua-statsd-client.

ramamoob avatar ramamoob commented on June 29, 2024

I am able to set the table values like this

local statsd = require "statsd"
  statsd["host"] = CONFIG.STATSD.HOST
  statsd["port"] = CONFIG.STATSD.PORT
  statsd["namespace"] = CONFIG.STATSD.NAMESPACE

When I try to call the function

statsd.increment(message["status"], 1)

I get the error method

attempt to call field 'increment' (a nil value)

Instead if I do this

statsd:increment(message["status"],1)

then I get the error

attempt to call method 'increment' (a nil value)

from lua-statsd-client.

ramamoob avatar ramamoob commented on June 29, 2024

I think I made some progress. Right now I can confirm that it is loading the correct statsd.lua. But is failing within that code on line #22.

2015/10/23 20:45:42 [error] 4187#0: lua entry thread aborted: runtime error: /usr/local/share/lua/5.1/statsd.lua:22: attempt to index local 'stat' (a nil value)
stack traceback:
coroutine 0:
        /usr/local/share/lua/5.1/statsd.lua: in function 'make_statsd_message'
        /usr/local/share/lua/5.1/statsd.lua:67: in function 'increment'

Which is

https://github.com/stvp/lua-statsd-client/blob/master/src/statsd.lua#L22

from lua-statsd-client.

ramamoob avatar ramamoob commented on June 29, 2024

you can close this case. Thanks for all your help.

from lua-statsd-client.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.