Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Metric Point to a Metric #2576

Closed
submah opened this issue Jun 15, 2017 · 11 comments
Closed

Add a Metric Point to a Metric #2576

submah opened this issue Jun 15, 2017 · 11 comments

Comments

@submah
Copy link

submah commented Jun 15, 2017

Hi,

I am trying to add a value to a predefined metrics, while executing the curl command with required parameters am getting the 400 errors. Here is the sample curl command

curl --request POST --url http://X.X.X.X/api/v1/metrics/{id}/points -H "X-Cachet-Token: xxxxxxxxxx" -H "Content-Type: application/json;" --data '{"value":1.34,"timestamp":"2017-06-15 14:52:23"}'

Output:

status":500,"title":"Internal Server Error","detail":"An error has occurred and this resource cannot be displayed."}]}

@jbrooksuk
Copy link
Member

Can you share your log file please? Looking at ./storage/logs.

@submah
Copy link
Author

submah commented Jun 16, 2017

Hi.
curl --request GET --url http://IP-Address/api/v1/metrics
{"meta":{"pagination":{"total":1,"count":1,"per_page":20,"current_page":1,"total_pages":1,"links":{"next_page":null,"previous_page":null}}},"data":[{"id":6,"name":"rcl-api","suffix":"rcl-api","description":"rcl-api","default_value":10,"calc_type":1,"display_chart":true,"places":2,"default_view":1,"created_at":"2017-06-14 17:15:00","updated_at":"2017-06-15 13:08:13"}]}

curl --request POST --url http://IP-Address/api/v1/metrics/6/points -H "X-Cachet-Token: sKWn3XXXXXXXXXP06em1" -H "Content-Type: application/json;" --data '{"value":1,"timestamp":"14:29:23"}'

Terminal Response:
{"errors":[{"id":"7d76903f-e705-4a9d-b131-c585d0a8c864","status":500,"title":"Internal Server Error","detail":"An error has occurred and this resource cannot be displayed."}]}

Log Response:

[2017-06-16 08:59:30] production.ERROR: InvalidArgumentException: Trailing data in /var/www/Cachet/vendor/nesbot/carbon/src/Carbon/Carbon.php:425
Stack trace:
#0 /var/www/Cachet/vendor/jenssegers/date/src/Date.php(86): Carbon\Carbon::createFromFormat('U', '14:29:23', 'Asia/Kolkata')
#1 /var/www/Cachet/app/Dates/DateFactory.php(58): Jenssegers\Date\Date::createFromFormat('U', '14:29:23', 'Asia/Kolkata')
#2 /var/www/Cachet/app/Bus/Handlers/Commands/Metric/AddMetricPointCommandHandler.php(58): CachetHQ\Cachet\Dates\DateFactory->create('U', '14:29:23')
#3 [internal function]: CachetHQ\Cachet\Bus\Handlers\Commands\Metric\AddMetricPointCommandHandler->handle(Object(CachetHQ\Cachet\Bus\Commands\Metric\AddMetricPointCommand))
#4 /var/www/Cachet/vendor/alt-three/bus/src/Dispatcher.php(225): call_user_func(Array, Object(CachetHQ\Cachet\Bus\Commands\Metric\AddMetricPointCommand))
#5 [internal function]: AltThree\Bus\Dispatcher->AltThree\Bus{closure}(Object(CachetHQ\Cachet\Bus\Commands\Metric\AddMetricPointCommand))
#6 /var/www/Cachet/bootstrap/cache/compiled.php(9674): call_user_func(Object(Closure), Object(CachetHQ\Cachet\Bus\Commands\Metric\AddMetricPointCommand))
#7 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(CachetHQ\Cachet\Bus\Commands\Metric\AddMetricPointCommand))
#8 /var/www/Cachet/bootstrap/cache/compiled.php(9656): call_user_func(Object(Closure), Object(CachetHQ\Cachet\Bus\Commands\Metric\AddMetricPointCommand))
#9 /var/www/Cachet/vendor/alt-three/bus/src/Dispatcher.php(226): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#10 /var/www/Cachet/vendor/alt-three/bus/src/Dispatcher.php(201): AltThree\Bus\Dispatcher->dispatchNow(Object(CachetHQ\Cachet\Bus\Commands\Metric\AddMetricPointCommand), NULL)
#11 /var/www/Cachet/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(281): AltThree\Bus\Dispatcher->dispatch(Object(CachetHQ\Cachet\Bus\Commands\Metric\AddMetricPointCommand))
#12 /var/www/Cachet/app/Http/Controllers/Api/MetricPointController.php(51): dispatch(Object(CachetHQ\Cachet\Bus\Commands\Metric\AddMetricPointCommand))
#13 [internal function]: CachetHQ\Cachet\Http\Controllers\Api\MetricPointController->postMetricPoints(Object(CachetHQ\Cachet\Models\Metric))
#14 /var/www/Cachet/bootstrap/cache/compiled.php(9137): call_user_func_array(Array, Array)
#15 /var/www/Cachet/bootstrap/cache/compiled.php(9199): Illuminate\Routing\Controller->callAction('postMetricPoint...', Array)
#16 /var/www/Cachet/bootstrap/cache/compiled.php(9179): Illuminate\Routing\ControllerDispatcher->call(Object(CachetHQ\Cachet\Http\Controllers\Api\MetricPointController), Object(Illuminate\Routing\Route), 'postMetricPoint...')
#17 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#18 /var/www/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#19 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#20 /var/www/Cachet/bootstrap/cache/compiled.php(9656): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#21 /var/www/Cachet/bootstrap/cache/compiled.php(9180): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#22 /var/www/Cachet/bootstrap/cache/compiled.php(9167): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(CachetHQ\Cachet\Http\Controllers\Api\MetricPointController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'postMetricPoint...')
#23 /var/www/Cachet/bootstrap/cache/compiled.php(8262): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'CachetHQ\Cachet...', 'postMetricPoint...')
#24 /var/www/Cachet/bootstrap/cache/compiled.php(8249): Illuminate\Routing\Route->runController(Object(Illuminate\Http\Request))
#25 /var/www/Cachet/bootstrap/cache/compiled.php(7977): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#26 [internal function]: Illuminate\Routing\Router->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#27 /var/www/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#28 /var/www/Cachet/app/Http/Middleware/ApiAuthentication.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#29 [internal function]: CachetHQ\Cachet\Http\Middleware\ApiAuthentication->handle(Object(Illuminate\Http\Request), Object(Closure), 'true')
#30 /var/www/Cachet/bootstrap/cache/compiled.php(9666): call_user_func_array(Array, Array)
#31 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#32 /var/www/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#33 /var/www/Cachet/app/Http/Middleware/Timezone.php(52): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#34 [internal function]: CachetHQ\Cachet\Http\Middleware\Timezone->handle(Object(Illuminate\Http\Request), Object(Closure))
#35 /var/www/Cachet/bootstrap/cache/compiled.php(9666): call_user_func_array(Array, Array)
#36 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#37 /var/www/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#38 /var/www/Cachet/app/Http/Middleware/Acceptable.php(34): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#39 [internal function]: CachetHQ\Cachet\Http\Middleware\Acceptable->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 /var/www/Cachet/bootstrap/cache/compiled.php(9666): call_user_func_array(Array, Array)
#41 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#42 /var/www/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#43 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#44 /var/www/Cachet/bootstrap/cache/compiled.php(9656): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#45 /var/www/Cachet/bootstrap/cache/compiled.php(7978): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#46 /var/www/Cachet/bootstrap/cache/compiled.php(7969): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#47 /var/www/Cachet/bootstrap/cache/compiled.php(7959): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#48 /var/www/Cachet/bootstrap/cache/compiled.php(2381): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#49 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}(Object(Illuminate\Http\Request))
#50 /var/www/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#51 /var/www/Cachet/bootstrap/cache/compiled.php(3183): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#52 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#53 /var/www/Cachet/bootstrap/cache/compiled.php(9666): call_user_func_array(Array, Array)
#54 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#55 /var/www/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#56 /var/www/Cachet/vendor/fideloper/proxy/src/TrustProxies.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#57 [internal function]: Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#58 /var/www/Cachet/bootstrap/cache/compiled.php(9666): call_user_func_array(Array, Array)
#59 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#60 /var/www/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#61 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#62 /var/www/Cachet/bootstrap/cache/compiled.php(9656): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#63 /var/www/Cachet/bootstrap/cache/compiled.php(2328): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#64 /var/www/Cachet/bootstrap/cache/compiled.php(2312): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#65 /var/www/Cachet/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#66 {main} {"identification":{"id":"7d76903f-e705-4a9d-b131-c585d0a8c864"}}

Could you assist me on this please.

@clesauln
Copy link

clesauln commented Jun 19, 2017

Hello,

the reason is that you didn't specify the good timestamp. Try to pass a real timestamp ex:

{
  "value": "5.2",
  "timestamp": "1493197381"
}

@submah
Copy link
Author

submah commented Jun 20, 2017

Hi There,
Thank you for your valuable response.
I tried with the correct timestamp value but still no luck. getting below response while adding a metric point to a metric.

here is the terminal output:

curl --request POST --url http://10.170.9.156/v1/metrics/6/points -H "X-Cachet-Token: sKWn3X0O1fLpY6P06em1" -H "Content-Type: application/json;" --data '{"value":"5.2","timestamp":"1497954204"}'
<!doctype html>

<title>Error 404</title> <style type="text/css"> @import url(//fonts.googleapis.com/css?family=Droid+Sans); html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;font-family:sans-serif;color:#222;} body{font-family:'Droid Sans', sans-serif;font-size:11pt;color:#555;line-height:25px;margin:0;} a{color:#00e;} a:visited{color:#551a8b;} a:hover{color:#72ADD4;} a:focus{outline:thin dotted;} a:hover,a:active{outline:0;} hr{display:block;height:1px;border:0;border-top:1px solid #ccc;margin:1em 0;padding:0;} .wrapper{padding: 3% 6%; margin:0 auto 5em;} @media (min-width: 768px) { html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;font-family:sans-serif;color:#222;} body{font-size:10pt;} a{color:#00e;} .wrapper{max-width: 768px} a,a:visited{color:#2972A3;} .row-fluid [class*="span"]{float:left;width:100%;margin-left:2.0744680851064%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;} .row-fluid [class*="span"]:first-child{margin-left:0;} .row-fluid .span3{width:99.946808510638%;} .row-fluid .span2{width:57.393617021277%;} .row-fluid .span1{width:40.372340425532%;} .pull-right{float:right;} .ellipsis{overflow: hidden;white-space: nowrap;text-overflow: ellipsis;-o-text-overflow: ellipsis;} } </style>

Error 404

Houston, We Have A Problem.

Not Found


        <h3>What does this mean?</h3>

        <p>
            Something went wrong on our servers while we were processing your request.
            The requested resource could not be found but may be available again in the future.
            This occurrence has been logged, and a highly trained team of monkeys has been
            dispatched to deal with your problem. We're really sorry about this, and will
            work hard to get this resolved as soon as possible.
        </p>
        <p>
            This error can be identified by <i>899e68f2-0035-4a90-b0e6-1f5e912c36bf</i>.
            You might want to take a note of this code.
        </p>
        <p>
            Perhaps you would like to go to our <a href="http://10.170.9.156/">home page</a>?
        </p>
    </div>
</div>

@submah
Copy link
Author

submah commented Jun 20, 2017

Hi,

It's working for me now with the below command:

curl --request POST --url http://10.170.9.156/api/v1/metrics/6/points -H "X-Cachet-Token: sKWn3X0O1fLpY6P06em1" -H "Content-Type: application/json;" --data '{"value":2.5,"timestamp":1497952190}'

output:

{"data":{"metric_id":6,"value":2,"created_at":"2017-06-20 15:19:50","updated_at":"2017-06-20 16:15:03","id":1}}

Thank you,
Subrat

@clesauln
Copy link

clesauln commented Jun 20, 2017 via email

@submah
Copy link
Author

submah commented Jun 20, 2017

Hi,

How can i update the value data and the timestamp data dynamically to cached metric point.
please refer to the below data both the value and timestamp are static data i.e. '{"value":2.5,"timestamp":1497952190}'. Could you suggest me how can i dynamically update ?

@clesauln
Copy link

clesauln commented Jul 4, 2017 via email

@jbrooksuk
Copy link
Member

We'd like to see a PR @clemaurny!

@clesauln
Copy link

clesauln commented Aug 21, 2017 via email

@jbrooksuk
Copy link
Member

We'd love to see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants