Fix lua issues in elasticsearch hidnsight part

In this CR issues with global variables, dot in ES fields and
port template have been fixed.

Change-Id: I819d9ca5f54500ef1dde8941d34deb3110e4bbf8
This commit is contained in:
Ilya Tyaptin 2016-09-23 17:35:45 +03:00
parent 899ca96af5
commit 9fe5872f62
3 changed files with 10 additions and 4 deletions

View File

@ -11,8 +11,12 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
require "string"
require "cjson"
local string = require "string"
local cjson = require "cjson"
local utils = require "lma_utils"
local table = require "table"
local pairs = pairs
local read_message = read_message
local utils = require "lma_utils"
local index = read_config("index") or "index"

View File

@ -68,6 +68,8 @@ local resource_msg = {
}
function add_resource_to_payload(sample, payload)
local counter_name, _ = string.gsub(sample.counter_name, "%.", "\\")
local resource_data = {
timestamp = sample.timestamp,
resource_id = sample.resource_id,
@ -76,7 +78,7 @@ function add_resource_to_payload(sample, payload)
user_id = sample.user_id,
project_id = sample.project_id,
meter = {
[sample.counter_name] = {
[counter_name] = {
type = sample.counter_type,
unit = sample.counter_unit
}

View File

@ -182,4 +182,4 @@ function timer_event(ns, shutdown)
end
end
end
end
end