Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing scheme on default exporter #259

Merged
merged 1 commit into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions promgen/migrations/0018_default_exporter_scheme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 2.2.10 on 2020-03-16 08:16

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('promgen', '0017_alter_alertlabel_field'),
]

operations = [
migrations.AddField(
model_name='defaultexporter',
name='scheme',
field=models.CharField(choices=[('http', 'http'), ('https', 'https')], default='http', help_text='Scrape exporter over http or https', max_length=5),
),
migrations.AlterField(
model_name='defaultexporter',
name='job',
field=models.CharField(help_text='Exporter name. Example node, jmx, app', max_length=128),
),
migrations.AlterField(
model_name='defaultexporter',
name='path',
field=models.CharField(blank=True, help_text='Exporter path. Defaults to /metrics', max_length=128),
),
migrations.AlterField(
model_name='defaultexporter',
name='port',
field=models.IntegerField(help_text='Port Exporter is running on'),
),
]
28 changes: 13 additions & 15 deletions promgen/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def __str__(self):
return '{} [{}]'.format(self.name, self.farm.name)


class Exporter(models.Model):
class BaseExporter(models.Model):
job = models.CharField(
max_length=128, help_text="Exporter name. Example node, jmx, app"
)
Expand All @@ -325,27 +325,25 @@ class Exporter(models.Model):
max_length=128, blank=True, help_text="Exporter path. Defaults to /metrics"
)
scheme = models.CharField(
max_length=5, choices=(("http", "http"), ("https", "https")), default="http", help_text="Scrape exporter over http or https"
max_length=5,
choices=(("http", "http"), ("https", "https")),
default="http",
help_text="Scrape exporter over http or https",
)

project = models.ForeignKey("Project", on_delete=models.CASCADE)
enabled = models.BooleanField(default=True)

class Meta:
ordering = ['job', 'port']
unique_together = (('job', 'port', 'project',),)
abstract = True

def __str__(self):
return '{}:{}:{} ({})'.format(self.job, self.port, self.path, self.project)

def get_absolute_url(self):
return reverse('project-detail', kwargs={'pk': self.project.pk})
class DefaultExporter(BaseExporter):
class Meta:
ordering = ["job", "port"]
unique_together = (("job", "port", "path"),)


class DefaultExporter(models.Model):
job = models.CharField(max_length=128)
port = models.IntegerField()
path = models.CharField(max_length=128, blank=True)
class Exporter(BaseExporter):
project = models.ForeignKey("Project", on_delete=models.CASCADE)
enabled = models.BooleanField(default=True)

class Meta:
ordering = ["job", "port"]
Expand Down
1 change: 1 addition & 0 deletions promgen/templates/promgen/exporter_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ <h1>Project: {{ project.name }}</h1>
<input type="hidden" name="job" value="{{ default.job }}" />
<input type="hidden" name="port" value="{{ default.port }}" />
<input type="hidden" name="path" value="{{ default.path }}" />
<input type="hidden" name="scheme" value="{{ default.scheme }}" />
<input type="hidden" name="enabled" value="1" />
<div class="input-group-btn">
<button style="width:80%" class="btn btn-primary">Register {{ default.job }} :{{ default.port }}{{ default.path }}</button>
Expand Down