0

I have a VM running kairosDB on laptop A,the VM has two IPs: 192.168.119.132 : to access it from laptop A. 192.168.1.151 : to access from laptop B.

From both laptops i can access the web app without any issue from < IP >:8080.

  • Laptop A : If i execute the POST/GET request shown in the code, everything work perfectly. (using IP 192.168.119.132)

  • Laptop B : Only GET request works ! the post request return code 200, but no point is added to the db when using POST.

Any help to make the POST request work please?

const fetch = require("node-fetch");
let query = {
  "metrics": [{
    "tags": {},
    "name": "matric1",
    "group_by": [{
      "name": "tag",
      "tags": [
        "car_type",
        "host",
        "mode_type"
      ]
    }]
  }],
  "plugins": [],
  "cache_time": 0,
  "start_relative": {
    "value": "20",
    "unit": "seconds"
  }
};
let dataPoint = [{
  "name": "matric1",
  "type": "long",
  "value": 88,
  "timestamp": Math.floor(Date.now()),
  "tags": {
    "car_type": "TEST",
    "host": "TEST",
    "mode_type": "TEST"
  }
}];

function fetchData(query) {
  fetch('http://192.168.1.151:8080/api/v1/datapoints/query?query=' + JSON.stringify(query), {
      method: 'GET'
    })
    .then(res => res.json()) // expecting a json response
    .then(json => console.log(json));
}

function addDataPoint(dataPoint) {
  fetch('http://192.168.1.151:8080/api/v1/datapoints', {
      method: 'POST',
      body: JSON.stringify(dataPoint),
      headers: {
        'Content-Type': 'application/json'
      }
    })
    .then(res => console.log("successfully added !"))
}

addDataPoint(dataPoint);

fetchData(query);

1 Answers1

0

Did you check that your laptops are synchronized? You push with current date / time and query the last 20 seconds.

Relative date queries are decided on the server.

So it could happen that if you have 20+ seconds difference between the two machines that your point is not in the query time span.

Loic
  • 1,088
  • 7
  • 19