Skip to content

Commit

Permalink
LOGOM::ADDED:: Add the ability to define the spooling directory for D…
Browse files Browse the repository at this point in the history
…A queues
  • Loading branch information
frikilax committed Mar 20, 2024
1 parent c4709d8 commit 420eb47
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- [LOG_FORWARDER] [REDIS] Support for queues, sets, publish and streams modes for log insertion
- [LOGOMELASTICSEARCH] Handle log insertion errors returned by elasticsearch
- [LOGOM] Add the ability to define the spooling directory for DA queues
### Changed
- [DEPENDENCIES] Upgrade djongo and code for pymongo>=4
- [LOGOM] Code and logic factorization
Expand Down
28 changes: 19 additions & 9 deletions vulture_os/applications/logfwd/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class Meta:
model = LogOM
fields = ('name', 'enabled', 'send_as_raw', 'queue_size', 'dequeue_size', 'queue_timeout_shutdown',
'max_workers', 'new_worker_minimum_messages', 'worker_timeout_shutdown', 'enable_retry',
'enable_disk_assist', 'high_watermark', 'low_watermark', 'max_file_size', 'max_disk_space')
'enable_disk_assist', 'high_watermark', 'low_watermark', 'max_file_size', 'max_disk_space',
'spool_directory')

widgets = {
'enabled': CheckboxInput(attrs={"class": " js-switch"}),
Expand All @@ -68,11 +69,12 @@ class Meta:
'low_watermark': NumberInput(attrs={'class': 'form-control'}),
'max_file_size': NumberInput(attrs={'class': 'form-control'}),
'max_disk_space': NumberInput(attrs={'class': 'form-control'}),
'spool_directory': TextInput(attrs={'class': 'form-control'}),
}

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for field_name in ['high_watermark', 'low_watermark', 'max_file_size', 'max_disk_space']:
for field_name in ['high_watermark', 'low_watermark', 'max_file_size', 'max_disk_space', 'spool_directory']:
self.fields[field_name].required = False

def clean_name(self):
Expand Down Expand Up @@ -109,7 +111,7 @@ class Meta:
fields = ('name', 'enabled', 'file', 'flush_interval', 'async_writing', 'send_as_raw', 'retention_time',
'rotation_period', 'queue_size', 'dequeue_size', 'queue_timeout_shutdown', 'max_workers',
'new_worker_minimum_messages', 'worker_timeout_shutdown', 'enable_retry', 'enable_disk_assist',
'high_watermark', 'low_watermark', 'max_file_size', 'max_disk_space')
'high_watermark', 'low_watermark', 'max_file_size', 'max_disk_space', 'spool_directory')

widgets = {
'enabled': CheckboxInput(attrs={"class": " js-switch"}),
Expand All @@ -132,6 +134,7 @@ class Meta:
'low_watermark': NumberInput(attrs={'class': 'form-control'}),
'max_file_size': NumberInput(attrs={'class': 'form-control'}),
'max_disk_space': NumberInput(attrs={'class': 'form-control'}),
'spool_directory': TextInput(attrs={'class': 'form-control'}),
}

def clean_name(self):
Expand All @@ -154,7 +157,7 @@ class Meta:
fields = ('name', 'enabled', 'target', 'port', 'tls_enabled', 'x509_certificate', 'send_as_raw', 'queue_size',
'dequeue_size', 'queue_timeout_shutdown', 'max_workers', 'new_worker_minimum_messages',
'worker_timeout_shutdown', 'enable_retry', 'enable_disk_assist', 'high_watermark', 'low_watermark',
'max_file_size', 'max_disk_space')
'max_file_size', 'max_disk_space', 'spool_directory')

widgets = {
'enabled': CheckboxInput(attrs={"class": " js-switch"}),
Expand All @@ -176,6 +179,7 @@ class Meta:
'low_watermark': NumberInput(attrs={'class': 'form-control'}),
'max_file_size': NumberInput(attrs={'class': 'form-control'}),
'max_disk_space': NumberInput(attrs={'class': 'form-control'}),
'spool_directory': TextInput(attrs={'class': 'form-control'}),
}

def __init__(self, *args, **kwargs):
Expand All @@ -197,7 +201,7 @@ class Meta:
'expire_key', 'stream_outfield', 'stream_capacitylimit', 'send_as_raw',
'queue_size', 'dequeue_size', 'queue_timeout_shutdown', 'max_workers', 'new_worker_minimum_messages',
'worker_timeout_shutdown', 'enable_retry', 'enable_disk_assist', 'high_watermark', 'low_watermark',
'max_file_size', 'max_disk_space')
'max_file_size', 'max_disk_space', 'spool_directory')

widgets = {
'enabled': CheckboxInput(attrs={'class': 'js-switch'}),
Expand Down Expand Up @@ -225,6 +229,7 @@ class Meta:
'low_watermark': NumberInput(attrs={'class': 'form-control'}),
'max_file_size': NumberInput(attrs={'class': 'form-control'}),
'max_disk_space': NumberInput(attrs={'class': 'form-control'}),
'spool_directory': TextInput(attrs={'class': 'form-control'}),
}

def clean_key(self):
Expand All @@ -250,7 +255,7 @@ class Meta:
fields = ('name', 'enabled', 'target', 'port', 'protocol', 'zip_level', 'queue_size', 'dequeue_size',
'queue_timeout_shutdown', 'max_workers', 'new_worker_minimum_messages', 'worker_timeout_shutdown',
'enable_retry', 'enable_disk_assist', 'high_watermark', 'low_watermark', 'max_file_size',
'max_disk_space', 'ratelimit_interval', 'ratelimit_burst', 'send_as_raw')
'max_disk_space', 'spool_directory', 'ratelimit_interval', 'ratelimit_burst', 'send_as_raw')

widgets = {
'enabled': CheckboxInput(attrs={"class": " js-switch"}),
Expand All @@ -271,6 +276,7 @@ class Meta:
'low_watermark': NumberInput(attrs={'class': 'form-control'}),
'max_file_size': NumberInput(attrs={'class': 'form-control'}),
'max_disk_space': NumberInput(attrs={'class': 'form-control'}),
'spool_directory': TextInput(attrs={'class': 'form-control'}),
'ratelimit_interval': NumberInput(attrs={'class': 'form-control'}),
'ratelimit_burst': NumberInput(attrs={'class': 'form-control'}),
'send_as_raw': CheckboxInput(attrs={'class': 'form-control js-switch'})
Expand Down Expand Up @@ -301,7 +307,8 @@ class Meta:
fields = ('name', 'enabled', 'servers', 'es8_compatibility', 'data_stream_mode', 'retry_on_els_failures', 'index_pattern', 'uid', 'pwd',
'x509_certificate', 'send_as_raw', 'queue_size', 'dequeue_size', 'queue_timeout_shutdown',
'max_workers', 'new_worker_minimum_messages', 'worker_timeout_shutdown', 'enable_retry',
'enable_disk_assist', 'high_watermark', 'low_watermark', 'max_file_size', 'max_disk_space')
'enable_disk_assist', 'high_watermark', 'low_watermark', 'max_file_size', 'max_disk_space',
'spool_directory')

widgets = {
'enabled': CheckboxInput(attrs={"class": "js-switch"}),
Expand All @@ -327,6 +334,7 @@ class Meta:
'low_watermark': NumberInput(attrs={'class': 'form-control'}),
'max_file_size': NumberInput(attrs={'class': 'form-control'}),
'max_disk_space': NumberInput(attrs={'class': 'form-control'}),
'spool_directory': TextInput(attrs={'class': 'form-control'}),
}

def clean_index_pattern(self):
Expand Down Expand Up @@ -355,7 +363,7 @@ class Meta:
fields = ('name', 'enabled', 'db', 'collection', 'uristr', 'x509_certificate', 'send_as_raw', 'queue_size',
'dequeue_size', 'queue_timeout_shutdown', 'max_workers', 'new_worker_minimum_messages',
'worker_timeout_shutdown', 'enable_retry', 'enable_disk_assist', 'high_watermark', 'low_watermark',
'max_file_size', 'max_disk_space')
'max_file_size', 'max_disk_space', 'spool_directory')

widgets = {
'enabled': CheckboxInput(attrs={"class": " js-switch"}),
Expand All @@ -376,6 +384,7 @@ class Meta:
'low_watermark': NumberInput(attrs={'class': 'form-control'}),
'max_file_size': NumberInput(attrs={'class': 'form-control'}),
'max_disk_space': NumberInput(attrs={'class': 'form-control'}),
'spool_directory': TextInput(attrs={'class': 'form-control'}),
}


Expand All @@ -387,7 +396,7 @@ class Meta:
'partitions_auto', 'confParam', 'topicConfParam', 'queue_size', 'dequeue_size',
'queue_timeout_shutdown', 'max_workers', 'new_worker_minimum_messages', 'worker_timeout_shutdown',
'enable_retry', 'enable_disk_assist', 'high_watermark', 'low_watermark', 'max_file_size',
'max_disk_space')
'max_disk_space', 'spool_directory')

widgets = {
'enabled': CheckboxInput(attrs={"class": " js-switch"}),
Expand All @@ -413,6 +422,7 @@ class Meta:
'low_watermark': NumberInput(attrs={'class': 'form-control'}),
'max_file_size': NumberInput(attrs={'class': 'form-control'}),
'max_disk_space': NumberInput(attrs={'class': 'form-control'}),
'spool_directory': TextInput(attrs={'class': 'form-control'}),
}

def __init__(self, *args, **kwargs):
Expand Down
9 changes: 9 additions & 0 deletions vulture_os/applications/logfwd/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ class LogOM (models.Model):
verbose_name=_("Max disk space used by the queue in MB (set to zero to disable)"),
validators=[MinValueValidator(0)]
)
spool_directory = models.TextField(
default="/var/tmp",
null=False,
help_text=_("Defines an existing folder to store queue files into"),
verbose_name=_("Existing folder to store queue files to"),
validators=[RegexValidator(
regex=r"^/.*$",
message="Value should be a valid fullpath, beginning with a '/'"
)])
send_as_raw = models.BooleanField(
default=False,
help_text=_("Send logs without any modification"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,17 @@ <h4><i class="icon fa fa-ban"></i> Form errors </h4>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="col-sm-4 control-label">{{form.spool_directory.label}}</label>
<div class="col-sm-5">
{{form.spool_directory}}
{{form.spool_directory.errors|safe}}
</div>
</div>
</div>
</div>
</div> <!-- /.tab-disk -->
</div> <!-- /.tab-queue -->
</div> <!-- /.advanced_options -->
Expand Down
11 changes: 11 additions & 0 deletions vulture_os/applications/templates/apps/logfwd_LogOMFWD.html
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,17 @@ <h4><i class="icon fa fa-ban"></i> Form errors </h4>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="col-sm-4 control-label">{{form.spool_directory.label}}</label>
<div class="col-sm-5">
{{form.spool_directory}}
{{form.spool_directory.errors|safe}}
</div>
</div>
</div>
</div>
</div> <!-- /.tab-disk -->
</div> <!-- /.tab-queue -->
</div> <!-- Advanced tab -->
Expand Down
11 changes: 11 additions & 0 deletions vulture_os/applications/templates/apps/logfwd_LogOMFile.html
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,17 @@ <h1 class="panel-title"><i class="fa fa-sitemap">&nbsp;</i>{% translate "Local F
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="col-sm-4 control-label">{{form.spool_directory.label}}</label>
<div class="col-sm-5">
{{form.spool_directory}}
{{form.spool_directory.errors|safe}}
</div>
</div>
</div>
</div>
</div> <!-- /.tab-disk -->
</div> <!-- /.tab-queue -->
</div> <!-- /.advanced_options -->
Expand Down
11 changes: 11 additions & 0 deletions vulture_os/applications/templates/apps/logfwd_LogOMHIREDIS.html
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,17 @@ <h4><i class="icon fa fa-ban"></i> Form errors </h4>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="col-sm-4 control-label">{{form.spool_directory.label}}</label>
<div class="col-sm-5">
{{form.spool_directory}}
{{form.spool_directory.errors|safe}}
</div>
</div>
</div>
</div>
</div> <!-- /.tab-disk -->
</div> <!-- /.tab-queue -->
</div> <!-- /.advanced_options -->
Expand Down
11 changes: 11 additions & 0 deletions vulture_os/applications/templates/apps/logfwd_LogOMKAFKA.html
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,17 @@ <h4><i class="icon fa fa-ban"></i> Form errors </h4>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="col-sm-4 control-label">{{form.spool_directory.label}}</label>
<div class="col-sm-5">
{{form.spool_directory}}
{{form.spool_directory.errors|safe}}
</div>
</div>
</div>
</div>
</div> <!-- /.tab-disk -->
</div> <!-- /.tab-queue -->
</div> <!-- /.advanced_options -->
Expand Down
11 changes: 11 additions & 0 deletions vulture_os/applications/templates/apps/logfwd_LogOMMongoDB.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ <h1 class="panel-title"><i class="fa fa-sitemap">&nbsp;</i>{% translate "MongoDB
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="col-sm-4 control-label">{{form.spool_directory.label}}</label>
<div class="col-sm-5">
{{form.spool_directory}}
{{form.spool_directory.errors|safe}}
</div>
</div>
</div>
</div>
</div> <!-- /.tab-disk -->
</div> <!-- /.tab-queue -->
</div> <!-- /.advanced_options -->
Expand Down
11 changes: 11 additions & 0 deletions vulture_os/applications/templates/apps/logfwd_LogOMRELP.html
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,17 @@ <h4><i class="icon fa fa-ban"></i> Form errors </h4>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="col-sm-4 control-label">{{form.spool_directory.label}}</label>
<div class="col-sm-5">
{{form.spool_directory}}
{{form.spool_directory.errors|safe}}
</div>
</div>
</div>
</div>
</div> <!-- /.tab-disk -->
</div> <!-- /.tab-queue -->
</div> <!-- /.advanced_options -->
Expand Down

0 comments on commit 420eb47

Please sign in to comment.