rickspencer3 / boring-obervability Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
I found this by running a check against a local web server that I didn't run.
Get this error:
[2023-04-07 16:49:03,916] ERROR in check_job: {'check_id': 6, 'check_name': 'local host', 'exception': "HTTPConnectionPool(host='127.0.0.1', port=5052): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x13820d220>: Failed to establish a new connection: [Errno 61] Connection refused'))"}
https://chat.openai.com/chat/4842963a-2620-4ba0-b7f3-249273c4df3f
ex: if you enter a check without "http:" or "https:" it throws a terrible error
from app.extensions import db
from app.models.header_check import header_check
from cryptography.fernet import Fernet
from flask import current_app
class Header(db.Model):
__tablename__ = 'headers'
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
name = db.Column(db.String(100))
key = db.Column(db.String(100))
_value = db.Column("value", db.LargeBinary) # Change the column name to "_value" and type to db.LargeBinary
user = db.relationship("User", back_populates="headers")
checks = db.relationship('Check', secondary=header_check, backref='headers')
@property
def value(self):
f = Fernet(current_app.config['FERNET_KEY'])
return f.decrypt(self._value).decode('utf-8')
@value.setter
def value(self, plaintext_value):
f = Fernet(current_app.config['FERNET_KEY'])
self._value = f.encrypt(plaintext_value.encode('utf-8'))
```
just so you can see that it's working as the graphs are rendered on the server
class WebHookChannel(NotificationChannel):
id = db.Column(db.Integer, db.ForeignKey('notification_channels.id'), primary_key=True)
method = db.Column(db.String(10))
url = db.Column(db.String(255))
headers = relationship("Header", back_populates="webhook_channel")
__mapper_args__ = {
'polymorphic_identity': 'webhook_channel',
}
class Header(db.Model):
__tablename__ = 'headers'
# ...
webhook_channel_id = db.Column(db.Integer, db.ForeignKey('webhook_channels.id'))
webhook_channel = relationship("WebHookChannel", back_populates="headers")
The name of a check is recorded in influxdb, so should be able use that to format graphs.
sql = f"""
SELECT
date_bin(interval '{interval}', time, TIMESTAMP '2001-01-01 00:00:00Z') as binned,
avg(elapsed) /1000 as elapsed,
id
FROM checks
WHERE time > now() - INTERVAL '{time_range_start}'
AND id in {_check_ids_for_user()}
GROUP BY id, binned
ORDER BY id, binned
"""
replace id, with name and remove the AND clause
eventually this could be configurable.
Also, when you do notify, send a summary of the last 10 minutes
If there have been no anomalies detected the anomalies table encounters an error
Should catch the condition where the table was not created and return a string or something. Maybe combine it with when there are no anomalies in the interval queried as well instead of returning just am empty table
import uuid
from sqlalchemy import String, BLOB
from sqlalchemy.ext.hybrid import hybrid_property
from flask_login import UserMixin
from app.extensions import db
class User(db.Model, UserMixin):
__tablename__ = 'users'
id = db.Column(String(36), primary_key=True, default=str(uuid.uuid4()), unique=True, nullable=False)
# Other columns go here
@hybrid_property
def get_id(self):
return self.id
To customize the login and registration pages in Flask-User, you can create your own templates that extend Flask-User's base templates and include your own branding and styles. Here's a step-by-step guide on how to do this:
Create a templates folder in your Flask application directory if you haven't done so already.
In the templates folder, create a new HTML file called login.html to customize the login page. This template should extend Flask-User's base.html and override the content block. Include your own branding, styles, and any additional content you'd like.
{% extends "flask_user/user_base.html" %}
{% block content %}
<div id="your_branding_container">
<!-- Add your branding, logo, or heading here -->
</div>
<div id="login_container">
<!-- Include the original Flask-User login form -->
{% include "flask_user/login_or_register_form.html" %}
</div>
<!-- Add your own styles or link to your stylesheets -->
<style>
/* Add custom styles for your branding and login form */
</style>
{% endblock %}
Similarly, create a new HTML file called register.html to customize the registration page:
{% extends "flask_user/user_base.html" %}
{% block content %}
<div id="your_branding_container">
<!-- Add your branding, logo, or heading here -->
</div>
<div id="register_container">
<!-- Include the original Flask-User registration form -->
{% include "flask_user/login_or_register_form.html" %}
</div>
<!-- Add your own styles or link to your stylesheets -->
<style>
/* Add custom styles for your branding and registration form */
</style>
{% endblock %}
Now, you need to tell Flask-User to use your custom templates for the login and registration views. In your Flask app configuration, add the following lines:
app.config['USER_LOGIN_TEMPLATE'] = 'login.html'
app.config['USER_REGISTER_TEMPLATE'] = 'register.html'
With these changes, Flask-User will use your custom login.html and register.html templates for the login and registration pages, respectively. You can now add your own branding, styles, and content to these pages by editing the templates.
If you want to customize other Flask-User templates, you can follow the same approach: create a new template that extends the base template, override the appropriate block, and update the corresponding configuration option. You can find the available template configuration options in the Flask-User documentation.
an anomaly detector that checks if the body contains or doesn't contain a string
Maybe make something polymorphic with headers, since they look much the same.
meaning, let users specify a maximum notification interval per notification channel
Show all the response data
i.e. window period is 1 minute, 10 minutes, 1 hour, 4 hours
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.