add new streaming app
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s

This commit is contained in:
2026-08-05 13:01:06 +01:00
parent 21e77ab0b3
commit 822c42bd62
16 changed files with 76 additions and 90 deletions
-7
View File
@@ -1,7 +0,0 @@
from django.apps import AppConfig
class NetdataLoggingConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.netdata_logging'
label = 'netdata_logging'
@@ -1,23 +0,0 @@
# =====================================================================
# NETDATA CONNECTION CONFIG - TEMPORARY / HARDCODED
#
# These values are kept in plaintext here ONLY until they are moved into
# the secret manager (see apps/bitwarden). Treat everything below as
# something that must be migrated before this app is used beyond a local
# hello-world test.
#
# Current status: logger.py logs structured JSON to stdout, which is the
# supported way for Netdata's log collectors (systemd-journal / generic
# log source) to pick up application logs - it does NOT push over the
# network, so `room_token` below is not consumed by any code yet.
#
# `agent_host` / `agent_port` point at the Netdata Agent's dashboard/API
# port (read-only, no push support). They're recorded here so the values
# are in one obvious place, ready to be reused once a real push mechanism
# (StatsD or an OpenTelemetry log receiver, on their own ports - NOT
# agent_port) is confirmed enabled on this agent.
# =====================================================================
class netdata:
agent_host = "netdata-agent.netdata.svc"
agent_port = 19999 # Netdata Agent dashboard/API port - read-only, not used to push logs
room_token = "" # Netdata Cloud room token - NOT currently used by any code in this app
@@ -1,44 +0,0 @@
"""
Structured logging helper for Netdata.
Netdata does not expose a generic "push a log line" API reachable with
just a room token from outside an Agent (see credentials.py). Until a
real push mechanism (StatsD or an OpenTelemetry log receiver) is
confirmed enabled on the agent, the supported path is the standard one:
emit structured JSON lines to stdout, which Netdata's log collectors
(systemd-journal / generic log source) are built to tail and parse.
"""
import logging
import sys
from pythonjsonlogger import jsonlogger
from .credentials import netdata
_LOGGER_NAME = "netdata"
def get_netdata_logger() -> logging.Logger:
logger = logging.getLogger(_LOGGER_NAME)
if not logger.handlers:
handler = logging.StreamHandler(stream=sys.stdout)
handler.setFormatter(
jsonlogger.JsonFormatter("%(asctime)s %(levelname)s %(name)s %(message)s")
)
logger.addHandler(handler)
logger.setLevel(logging.INFO)
logger.propagate = False
return logger
def log_event(message, level="info", **fields):
"""Log a structured event intended to be picked up by Netdata.
Extra keyword arguments are attached as structured fields on the JSON
log line, e.g. log_event("hello world", source="netdata_logging.hello").
"""
logger = get_netdata_logger()
log_fn = getattr(logger, level.lower(), logger.info)
log_fn(message, extra={"netdata_agent_host": netdata.agent_host, **fields})
@@ -1,8 +0,0 @@
from django.http import HttpResponse
from .logger import log_event
def hello(request):
log_event("Hello world from netdata_logging!", source="netdata_logging.hello")
return HttpResponse('<h1>Hello Netdata logging!</h1>')
+3
View File
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
+6
View File
@@ -0,0 +1,6 @@
from django.apps import AppConfig
class StreamingConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.streaming'
@@ -0,0 +1,26 @@
# Generated by Django 4.2.30 on 2026-08-05 12:00
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='streamingData',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('url', models.CharField(max_length=1000)),
('addedDate', models.DateField(auto_now_add=True, null=True, verbose_name='Published')),
('status', models.CharField(blank=True, max_length=1000, null=True)),
],
options={
'db_table': 'streaming',
},
),
]
+10
View File
@@ -0,0 +1,10 @@
from django.db import models
# Create your models here.
class streamingData(models.Model):
url = models.CharField(max_length=1000)
addedDate = models.DateField('Published', blank=True, null=True, auto_now_add=True)
status = models.CharField(max_length=1000, blank=True, null=True)
class Meta:
db_table = 'streaming'
+3
View File
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
+3
View File
@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.