Comments (11)
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.
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.
I think this is almost complite example. I run it as service.
from lua-statsd-client.
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.
You use differen library i think
from lua-statsd-client.
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.
- try find out what table contain. e.g. print all key/values
for k,v in pairs(statsd) do print(k,v) end
- 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.
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.
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.
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.
you can close this case. Thanks for all your help.
from lua-statsd-client.
Related Issues (4)
- rockspec file fails to install HOT 1
- Upload to Luarocks, Moonrocks HOT 3
- Globals in v2.0.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-statsd-client.