Giter Site home page Giter Site logo

boring-obervability's Introduction

This project is licensed under the Apache License version 2. See: https://www.apache.org/licenses/LICENSE-2.0

Adding a new type of check

1. add the check to app/models.checks.py

when you name the type, keep in mind that it will be used to select the proper templates for example:

return render_template(f'checks/edit_{check.type}.html',
                form=form_classes[check.type](obj=check),
                check=check)

2. use flask db migrate and flask db upgrade to migrate the database

3. update CheckClass in app\models\__init__.py

4. create forms for the check in app/checks/forms.py

5. update FormClass in app/checks/forms.py

6. create new view

  • details_{type}.html
  • edit_{type}.html
  • new_{type}.html

7. add link to the new route with the type to app/templates/checks/index.html

boring-obervability's People

Contributors

rickspencer3 avatar

Watchers

 avatar

boring-obervability's Issues

For the graphs, select the name instead of id

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

make notification channels many to many for anomaly detectors

  • create anomaly_detector_notification_channels model
  • change anomaly_detector model to have a list of notification channel
  • run migration
  • change notification code to all all notification channels
  • add ui to add notification channels to a detector
  • add route to anomaly_detector to remove a notification_channel
  • add ui to remove a notification channel from a detector
  • call anomaly_detector.remove() from the javascript

check that times out does not get reported

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'))"}

Add Cookies

Maybe make something polymorphic with headers, since they look much the same.

Update the Header model to encrypt the values

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'))
        ```

factor the AnomalyDetector and NotificationChannel classes

  • Make anomaly detectors polymorphic
  • Move Anomaly detection to the detector subclasses
  • Make notification channels polymorphic
  • Move notification to the channel subclasses
  • Update the forms model for detectors
  • Update the forms model for channels
  • Update the create and update views for detectors
  • Update the create and update views for channels

make ids random strings instead of incrementing integers

  • users
  • checks
  • anomaly_detectors
  • notificaiton_channels
  • Headers
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

Handle no anomalies more elegantly

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

  • if the count of anomalies is 0, return a sensible string
  • capture the error returned when no table is present, and return the same string (this is a lower priority as it is a corner case due to the current status of IOx development

make web hook notification channel

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")

Style and brand the registration and login pages

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.

Finish header flow

  • Add new header UI from header index page
  • Add ability to select existing header from Checks page
  • Add Edit a header
  • Add Delete a header
  • Associate a header to a check (not just create a new one)
  • Change to remove headers from checks
  • Update checks index to include the name of the header

can't disable a check

  • Add enabled column to database via Flask-Migrate
  • Add enabled checkbox to grid on checks.index
  • Add route to response to checkbox being toggled
  • Only retrieve and run enabled checks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.