Setup Grafana alert on Loki's errors log - grafana

I have setup Grafana and loki (2.6.1 / 9.0), and I'd like to setup an alert whenever logs have Error as severity.
I have this query:
count (rate({namespace="api-dev"} |= `"severity":"Error"` [5m]))
Which gives me what I want:
However, even few hours later, the alert is still firing.
Is there a proper way to be notified whenever a new error log is found, but not too much (eg. not more than twice per hour)?
PS: I had a look at this answer, but the issue persists.

Related

Flutter and Firebase Analytics - events are not logged (but sometimes works)

I have a simple application, to which I just added Firebase.
Since 4 days I am trying to make it work, and yesterday finally I started seeing events coming in DebugView (which proves that I configured it correctly). It was moment of pure joy, as each single event was recorded in DebugView (no matter how many times I clicked a button -> all events reached Firebase).
This happiness didn't last long however.
Today it stopped work, but not like "never works", but it skips like 95-99% of events (some events sometimes gets to DebugView. Wow! Pure magic.
Using logcat, I can see all events are successfully uploaded/sent.
I wonder if there is any undocumented "magical" thing that might me blocking my events?
Or is Firebase down today (21st Sept 2022)?
Please note that:
When my events passes - it shows "1" in USERS IN LAST 30 MINUTES which is correct.
When events are not reaching DebugView, then nothing is shown in USERS IN LAST 30 MINUTES (which basically means that it is not only problem with DebugView - but actually no activity is reaching Firebase AT ALL).
Following picture proves that some events reached Firebase (but dozens other events, like screen_view or my custom dummy_event never got there).
Last picture proves that my events actually are successfully sent.
EDIT 25th Sept 2022
I deleted Firebase project and created a new one, run flutterfire configure and guess what? It started to work WITHOUT any other change in the code. (please note that I was running flutterfire configure many time for previous firebase project as well, without any result).
I am frustrated that I wasted few hours on looking for a bug in my code, while it was some "magic" on Firebase side that simply made it NOT WORKING.
So do you think it is over now? And that everything works?
You can't be farther from truth.
This image shows that there was 1 active user. Yes, it was me debugging app using DEBUG build. So since it was working, and decided to make final release build to my device (flutter run --release) and guess what?
Yeap - nothing shows in Firebase again. Simply my release build, installed on my device does not shows any activity on Firebase.
Is it because it was not downloaded from Google Play?
Is it because I have some misconfiguration?
Is it because Firebase has bug?
Who knows... Firebase is like Hogwart - full of magic.

Alerts in Grafana are not triggerd

I have Grafana and I would like to add some alerts.
I added TestData as my input since it makes the development easier.
My problem is that my alert is not triggered and when it's triggered, it never switches to OK.
What am I missing? I did save the dashboard after every change.
For example why in this screenshot the alert is not triggerd?

ACRA toast appearing, but cannot explain why

I have a complex Android app that uses ACRA for error reporting, which generally works fine.
Except, on one test device, I now see the ACRA toast appearing, during app startup, and then disappearing. But the app keeps running, and I get no report. It's as if an error happened, but nothing but a toast appeared. I find no clues in logcat.
But if I force a report by throwing an exception, I get the same toast, and I get the report posted to my server, and the app quits, all of which is desired behavior.
I've tried to track this down by adding a custom ReportingAdministrator just for the purpose of getting a stack trace. This works for my forced exception, but does get called for the mystery toast - the toast is displayed, but my administrator class method does not get called.
Any suggestions on how to find the cause of this errant toast event?
Note: ACRA is normally called by MyExceptionInterceptor. On an uncaught exception, it grabs some text and puts it uses the ACRA error report to add it to the report. It then calls ACRA.getErrorReporter().handleException(t, true);
Whatever is causing the ACRA toast to appear is not going through this path. I have not been able to find anywhere to set a breakpoint to catch it.
Setup code:
int acraLimitPerTime = VersionHelper.isDevelVersion() ? 1000 : 2;
CoreConfigurationBuilder builder = new CoreConfigurationBuilder(this)
.setBuildConfigClass(BuildConfig.class)
.setReportFormat(StringFormat.KEY_VALUE_LIST)
.setStopServicesOnCrash(true)
.setReportSendFailureToast("Error report could not be sent")
.setReportSendSuccessToast("Error report was sent")
.setEnabled(true)
.setExcludeMatchingSharedPreferencesKeys("^lat$", "^lng$");
builder.getPluginConfigurationBuilder(HttpSenderConfigurationBuilder.class)
.setUri(ISOL.URL_ACRA_REPORT)
.setHttpMethod(HttpSender.Method.POST)
.setBasicAuthLogin("*****")
.setBasicAuthPassword("*****")
.setEnabled(true);
builder.getPluginConfigurationBuilder(ToastConfigurationBuilder.class)
.setLength(Toast.LENGTH_LONG) //===jrm
.setText("An error has occurred and a report is being sent to the developer.")
.setEnabled(true);
builder.getPluginConfigurationBuilder(LimiterConfigurationBuilder.class)
.setPeriodUnit(TimeUnit.HOURS)
.setPeriod(1)
.setOverallLimit(acraLimitPerTime)
.setEnabled(true);
// The following line triggers the initialization of ACRA
ACRA.init(this, builder);
ACRA.getErrorReporter().putCustomData("BUILDDTG", MyBuildConstants.buildDTG);
new MyExceptionInterceptor().setUpFatalExceptionHandling();
I have been observing this very same behavior on my application. From the code base, I could track down that Toast message is triggered due to an unapproved report during startup.
I am not sure how it got to this state, but I guess that application has been shutted down before report was sent. It happens that this report is never treated, so I consistently get Toast notification on app startup.
Anyway, I could avoid startup notification by two means: set checkReportsOnApplicationStart to false on ACRA.init call, or clean acra unapproved folder inside your app data.
You may refer to this pull request (https://github.com/ACRA/acra/pull/1078) to better locate methods that cause this behavior.

How to display or customize CRUD error messages in Flask Admin

What is the best way to display when there is error in Listing, Create, Delete or Edit? So far I have created model and custom BaseModelView. Everything seem to work in happy path. I tried throwing exception from the various methods that I had to implement my custom BaseModelView. It result in internal server error. This is probably expected, but how do I show custom error messages for these operation. Is there any provision in Flask Admin for showing custom error messages for the CRUD errors?
I tried Flash message. It worked just fine.

Zend Error controller stopped working for 500

My Zend application was running fine until today, when I changed something which caused the error controller to stop working.
I have debugged every part of the code but I can not find any traces as to why is it happening
If I produce a 404 error, the error controller runs perfectly. But in case of 500, the control does not go to error controller.
I have tried many things but am still unable to find out what's wrong. I have searched the internet but people who encountered this problem, seemed to get no answer :(
Any help would be much appreciable
I have debugged the application step by step and found out that in case of 500, the execution stops instantly when it encounters a fatal error or exception
(UPDATE)
If I do something like...
$blabla->getInfo();
where $blabla is not defined, I don't get redirected to error controller.
But if I do something like...
Zend_Registry::get('blabla');
where no key is set for 'blabla' in Zend_Registry, then I get redirected
500 is a general server error, so no wonder the control does not go to your controller.
You will need to check your server logs to find out what is causing the error.
Also, try to recall whether you have altered your .htaccess file(s) recently and/or created an infinite redirect loop by accident.