Export data to HTTP post

I am looking to export data to a vendor as it comes into our system. I was writing a kapacitor tickscript - but I cannot edit the structure of the json (slightly annoying) and am having difficulty getting it to post correctly.

Our DB is a big flat table (maybe not the best, but not my idea). We have 3 different sensors coming in (12 tags each sensor, total 36 tags). We need to constantly send the data to a vendor and kapacitor came up because it has a built in httppost function.

Problem:
First when i attempt to query and return the data, it only returns the first sensor (12 ish tags), but then returns blank rows for every other tag type. So i know its attempting, but i feel like there is a column limit in kapacitor or it cannot handle something I want it to do. Example (Fig1) below:

I can tell the lines are different because sn is common across 2 of them and is updating to the correct value. Then i started thinking "is this my lack of understanding of TSDBā€™s thatā€™s causing this?

So I thought, split this up into each sensor and do 3 separate kapacitor jobsā€¦ super annoying and not what iā€™m supposed to send, but maybe that worksā€¦ However then it starts sending bad/duplicate subsets of data. It will randomly post with columns 1 and 2, then send the same data with every column. I want it to only post if it sends every column.

The downside of the second approach is that itā€™s now 3 separate jsons because the post doesnā€™t have a join method on it for me to merge this all together. Can anyone lend some insight? Iā€™m clearly in over my head with kapacitor and am slowly starting to explore options outside of influx altogether.
edit I feel like telegraf might even be a better choice here?

Ideally I want to make my own json structure in here, but thatā€™s provingā€¦ ridiculous. Otherwise if I can get all the data into one json, that would be ideal.

"columns": ["time", "SweepCount", "Uptime", "Uptime_1", "boardTemp", "measurement", "rh", "s0TempPost", "s0TempPre", "s0mag", "s0phase", "s1TempPost", "s1TempPre", "s1mag", "s1phase", "s2TempPost", "s2TempPre", "s2mag", "s2phase", "s3TempPre", "s3mag", "s3phase", "s4TempPost", "s4TempPre", "s4mag", "s4phase", "sn"],
	"values": [
		["2020-07-27T20:59:35.493Z", 118, 10271, 10271, 8681, "EQUIP1", 15.73, 88.1395, 90.3608, 16369700, -5.98295, 87.9217, 88.0523, 15466700, -3.69109, 87.4885, 87.6181, 13641500, -27.205, 87.4022, 3110180, -76.1478, 87.144, 87.5317, 34950.5, -81.1914, 1627],
		["2020-07-27T20:59:35.533Z", null, null, null, null, "EQUIP1", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null],
		["2020-07-27T20:59:35.563Z", null, 10365, 10365, 100, "EQUIP1", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 6237],
1 Like

Hello @boris377,
Iā€™m sorry youā€™re having trouble. Yes, Kapacitor is tricky. Have you considered using Flux, Tasks, joins() and http.post?
I think you might have more success using flux than using kapacitor.

I have not, not even sure where to start though. The biggest thing is it needs to constantly stream data which is why Mike and I chose Kapacitor since it can run batch/streaming jobs. However it has been terrible and every time i go a step forward, i find a problem.

Also of note is that i am on the enterprise version, so i do not have flux 2.0, so what I can do MIGHT be limited in flux. I donā€™t know if the join method is included? When I go to add flux to the

That said if I started writing a tickscript that would just query the 3 rows, join together into one file, but join wasnā€™t supported in httppost for tickscript that I could find.

Any further ideas? Funny though, we pay for enterprise and can actually do less it seems :frowning:

P.S. In looking at your solution, ā€œTasksā€ is what I am using, these are kapacitor run jobsā€¦ so iā€™m not sure what is different here other than maybe using flux which i donā€™t think I have the option to?

Hi @boris377,

As I understand it:

Enterprise has Kapacitor support, but not Tasks support. You use Tick Script with Kapacitor.
2.0 has Tasks support, but not Kapacitor support. You use Flux with Tasks.

Essentially, Tasks are 2.0ā€™s answer to Kapacitor.

I think, therefore, that as an Enterprise customer, @Anaisdg suggestion wonā€™t work for you.

1 Like

Hello @boris377,
Can you please share your TICK script?

var data = batch
|query(ā€˜SELECT ā€œmeasurementā€,ā€œSnā€ as ā€œsnā€,ā€œDensityā€ as ā€œdensityā€,ā€œUptimeā€,ā€œSweepCountā€,ā€œS0TempPreā€ as ā€œs0TempPreā€,ā€œS0TempPostā€ as ā€œs0TempPostā€,ā€œS0magā€ as ā€œs0magā€,ā€œS0phaseā€ as ā€œs0phaseā€, ā€œS1TempPreā€ as ā€œs1TempPreā€,ā€œS1TempPostā€ as ā€œs1TempPostā€,ā€œS1magā€ as ā€œs1magā€,ā€œS1phaseā€ as ā€œs1phaseā€,ā€œS2TempPreā€ as ā€œs2TempPreā€
,ā€œS2TempPostā€ as ā€œs2TempPostā€,ā€œS2magā€ as ā€œs2magā€,ā€œS2phaseā€ as ā€œs2phaseā€,ā€œS3TempPreā€ as ā€œs3TempPreā€,ā€œS3TempPostā€ as ā€œs2TempPostā€
,ā€œS3magā€ as ā€œs3magā€,ā€œS3phaseā€ as ā€œs3phaseā€,ā€œS4TempPreā€ as ā€œs4TempPreā€,ā€œS4TempPostā€ as ā€œs4TempPostā€,ā€œS4magā€ as ā€œs4magā€
,ā€œS4phaseā€ as ā€œs4phaseā€,ā€œBoardTempā€ as ā€œboardTempā€,ā€œRHā€ as ā€œrhā€,ā€œDensityā€ as ā€œdensityā€,ā€œOil_tempā€ as ā€œoiltempā€,ā€œbelow_shortā€ as ā€œstatus_TF_below_shortā€
,ā€œabove_damagedā€ as ā€œstatus_TF_above_damagedā€,ā€œASIC_over_tempā€ as ā€œstatus_TF_ASIC_over_tempā€,ā€œfit_failedā€ as ā€œstatus_fit_failed_to_convergeā€
,ā€œRTD_res_below_shortedā€ as ā€œstatus_RTD_res_below_shortedā€,ā€œRTD_res_above_damagedā€ as ā€œstatus_RTD_res_above_damagedā€
,ā€œRTD_over_tempā€ as ā€œstatus_RTD_over_tempā€,ā€œsystem_errorā€ as ā€œstatus_system_errorā€,ā€œFerrous < 100ā€ as ā€œfeLt100ā€,ā€œFerrous 100-200ā€ as ā€œfe100_200ā€,ā€œFerrous 200-300ā€ as ā€œfe200_300ā€,ā€œFerrous 300-400ā€ as ā€œfe300_400ā€
,ā€œFerrous 400-500ā€ as ā€œfe400_500ā€,ā€œFerrous 500-600ā€ as ā€œfe500_600ā€,ā€œFerrous 600-700ā€ as ā€œfe600_700ā€,ā€œFerrous >700ā€ as ā€œfeGt700ā€
,ā€œNon-Ferrous < 200ā€ as ā€œnfLt200ā€,ā€œNon-Ferrous 200-300ā€ as ā€œnf200_300ā€,ā€œNon-Ferrous 300-400ā€ as ā€œnf300_400ā€,ā€œNon-Ferrous 400-500ā€ as ā€œnf400_500ā€
,ā€œNon-Ferrous 500-600ā€ as ā€œnf500_600ā€,ā€œNon-Ferrous 600-700ā€ as ā€œnf600_700ā€,ā€œNon-Ferrous 700-800ā€ as ā€œnf700_800ā€,ā€œNon-Ferrous > 800ā€ as ā€œnfGt800ā€,ā€œFlowRateā€ as ā€œflowRateā€
FROM ā€œMEM_Sensorā€.autogen.equipmentā€™)
// ā€œ-eā€,
.every(30s)
.period(3000s)
.align()
|httpPost()
.endpoint(ā€˜Poseidonā€™)
.captureResponse()

So there are 3 sensors in here.the S#'s are the first sensor, the status group second, and the Ferrous/Non-Ferrous third. I expect 3 rows because the timestamps for each sensor are a few hundredths of a second different, but what kapacitor does, is the first example I gaveā€¦ it throws out the first groups columns for all 3 timestamps.It seems to have a column limit or doesnā€™t know how to do multiple data columns? Join isnā€™t an option because HTTP in tickscript doesnā€™t support.

When I split it into 3 separate queries, it swaps between giving me all the items per sensor and only 2-4 columns from the query depending on when i capture the post.