cachet icon indicating copy to clipboard operation
cachet copied to clipboard

Internal Server Error (v 3) - Cachet\Http\Controllers\Api\MetricPointController::update does not exist.

Open NeikiDev opened this issue 9 months ago • 14 comments

Internal Server Error

PUT status.neiki.dev
PHP 8.3.16 — Laravel 11.39.1
Method Cachet\Http\Controllers\Api\MetricPointController::update does not exist.
vendor/laravel/framework/src/Illuminate/Routing/Controller.php :68
vendor/laravel/framework/src/Illuminate/Routing/Controller.php :54
vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php :44

I tried to put metrics points via put (apikey etc set and metric exists)

Also i am wondering why the error page shows database queries? is that normal i mean it shows a bunch of information cant that be used for malicious purposes?

const options = {
  method: 'PUT',
  headers: {Authorization: 'REDACTED'},
};


fetch("https://status.neiki.dev/api/metrics/4/points/1", options)
  .then(response => response.text())
  .then(response => console.log(response))
  .catch(err => console.error(err));

NeikiDev avatar Mar 07 '25 13:03 NeikiDev

It's not possible to update a metric point, we don't actually have an update method - https://github.com/cachethq/core/blob/main/src/Http/Controllers/Api/MetricPointController.php

@romalytvynenko it looks like Scramble isn't respecting the use of Laravel's apiResource method https://github.com/cachethq/core/blob/117787672da2cc91ad6d465ce35f41b4d2dc4062/routes/api.php#L25-L39

jbrooksuk avatar Mar 08 '25 09:03 jbrooksuk

Marking as a task, as we need to fix the documentation - there is no bug in Cachet itself.

jbrooksuk avatar Mar 08 '25 09:03 jbrooksuk

Hey, thanks for the fast response i really appreciate it. I looked at the docs here https://docs.cachethq.io/api-reference/metricpoint/put-metrics-points#put-metrics-points

Because on my site i created a metric graph but it wasnt showing on the statuspage so i thought i needed to use the api to update or create the metrics points first to make the graph visiable, suddenly i used this api path and got a big html error page which also showed a bunch of sql commands.

So i was curious first if that is normal and second what i did wrong.

Thanks tho for the clarification! <3

Can you maybe point me to the direct api documentation to update the metric graph with points to make it visiable on my cachet status page and also to monitor my api latency, because now i am kinda confused how the metrics works and how to update them

NeikiDev avatar Mar 08 '25 09:03 NeikiDev

Have you set APP_DEBUG=false in your .env file? This should prevent any errors from showing debug information.

In terms of documentation, I'm unsure why Scramble is documenting endpoints which don't exist. @romalytvynenko is the creator of Scramble and will know what to do here.

jbrooksuk avatar Mar 08 '25 17:03 jbrooksuk

Thank you very much, but i am confused because in the v3 demo i can see a metrics graph so there must be a way to create it and update it via api or smth? many thanks for the help!

NeikiDev avatar Mar 08 '25 17:03 NeikiDev

@jbrooksuk @NeikiDev looking into it!

romalytvynenko avatar Mar 09 '25 07:03 romalytvynenko

@NeikiDev you need to create points on the metric itself and make sure you have "Display Graphs" checked under "Manage Cachet".

jbrooksuk avatar Mar 09 '25 09:03 jbrooksuk

@jbrooksuk Hey thanks, but if i turn on "Display Graphs" in my dashboard under "Manage cachet" and save i reload the page it is disabled again and now metric graph is shown.

I update the settings: Image

I reload the page: Image

And is this the right API path to update the metric points?

https://docs.cachethq.io/api-reference/metric-points/create-metric-point#create-metric-point

NeikiDev avatar Mar 09 '25 09:03 NeikiDev

I just fixed a bug that was causing the setting to do nothing - graphs were always shown anyway.

That said, make sure the Metric itself is visible for users / guests and the option to display it is checked:

image

That endpoint is correct for adding new points.

jbrooksuk avatar Mar 09 '25 10:03 jbrooksuk

@jbrooksuk Hey, yep this are my metrics settings But no graph or metric visiable on my status page (https://status.neiki.dev/) I already used the api to even update points and it worked but the graph is not displayed. I also did like before i opened this issue a update to cachet via composer update cachethq/core

Any idea?

Image

NeikiDev avatar Mar 09 '25 10:03 NeikiDev

Speaking of API documentation, I fixed the issue with Scramble documenting update endpoint: https://github.com/cachethq/core/pull/258

By the way, MetricPointController@update method is registered here hence it was added to API documentation: https://github.com/cachethq/core/blob/117787672da2cc91ad6d465ce35f41b4d2dc4062/routes/api.php#L61-L63 You can see it by running route:list command.

romalytvynenko avatar Mar 09 '25 11:03 romalytvynenko

Any updates on this? i am still confused how to use the metrics properly

NeikiDev avatar Mar 20 '25 05:03 NeikiDev

@NeikiDev to confirm;

  1. You have created a Metric and it's visibility is not set to "Always Hidden".
  2. The "Display Chart" option is also enabled on the Metric.
  3. The metric has points.

jbrooksuk avatar Mar 20 '25 11:03 jbrooksuk

@jbrooksuk Image Image

This is my setup, the metric graph is not shown on the status page.

And idk how to add or manage the points of the metric that was one of my initla questions because the API was buggy

NeikiDev avatar Mar 21 '25 18:03 NeikiDev