From 9fe5872f62b0011cd7cae6c2a6ac34ec37c5287c Mon Sep 17 00:00:00 2001 From: Ilya Tyaptin Date: Fri, 23 Sep 2016 17:35:45 +0300 Subject: [PATCH] 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 --- .../telemetry/files/common/elasticsearch_resources.lua | 8 ++++++-- .../puppet/modules/telemetry/files/common/resources.lua | 4 +++- .../files/hindsight/run/output/elasticsearch_bulk_tcp.lua | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/deployment_scripts/puppet/modules/telemetry/files/common/elasticsearch_resources.lua b/deployment_scripts/puppet/modules/telemetry/files/common/elasticsearch_resources.lua index 06744ad..b77caa6 100644 --- a/deployment_scripts/puppet/modules/telemetry/files/common/elasticsearch_resources.lua +++ b/deployment_scripts/puppet/modules/telemetry/files/common/elasticsearch_resources.lua @@ -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" diff --git a/deployment_scripts/puppet/modules/telemetry/files/common/resources.lua b/deployment_scripts/puppet/modules/telemetry/files/common/resources.lua index 653ffff..465585b 100644 --- a/deployment_scripts/puppet/modules/telemetry/files/common/resources.lua +++ b/deployment_scripts/puppet/modules/telemetry/files/common/resources.lua @@ -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 } diff --git a/deployment_scripts/puppet/modules/telemetry/files/hindsight/run/output/elasticsearch_bulk_tcp.lua b/deployment_scripts/puppet/modules/telemetry/files/hindsight/run/output/elasticsearch_bulk_tcp.lua index d97c21d..ebb4670 100644 --- a/deployment_scripts/puppet/modules/telemetry/files/hindsight/run/output/elasticsearch_bulk_tcp.lua +++ b/deployment_scripts/puppet/modules/telemetry/files/hindsight/run/output/elasticsearch_bulk_tcp.lua @@ -182,4 +182,4 @@ function timer_event(ns, shutdown) end end end -end \ No newline at end of file +end