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

Sidecar collector rename #4903

Merged
merged 6 commits into from
Jul 19, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
@AutoValue
@JsonAutoDetect
public abstract class CollectorStatus {
@JsonProperty("name")
public abstract String name();
@JsonProperty("collector_id")
public abstract String collectorId();

@JsonProperty("status")
public abstract int status();
Expand All @@ -34,9 +34,9 @@ public abstract class CollectorStatus {
public abstract String message();

@JsonCreator
public static CollectorStatus create(@JsonProperty("name") String name,
public static CollectorStatus create(@JsonProperty("collector_id") String collectorId,
@JsonProperty("status") int status,
@JsonProperty("message") String message) {
return new AutoValue_CollectorStatus(name, status, message);
return new AutoValue_CollectorStatus(collectorId, status, message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,19 @@ public abstract class CollectorSummary {
@JsonProperty("node_operating_system")
public abstract String nodeOperatingSystem();

@JsonProperty("default_template")
public abstract String defaultTemplate();

@JsonCreator
public static CollectorSummary create(@JsonProperty("id") String id,
@JsonProperty("name") String name,
@JsonProperty("service_type") String serviceType,
@JsonProperty("node_operating_system") String nodeOperatingSystem,
@JsonProperty("default_template") String defaultTemplate) {
return new AutoValue_CollectorSummary(id, name, serviceType, nodeOperatingSystem, defaultTemplate);
@JsonProperty("node_operating_system") String nodeOperatingSystem) {
return new AutoValue_CollectorSummary(id, name, serviceType, nodeOperatingSystem);
}

public static CollectorSummary create(Collector collector) {
return create(
collector.id(),
collector.name(),
collector.serviceType(),
collector.nodeOperatingSystem(),
collector.defaultTemplate());
collector.nodeOperatingSystem());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const CollectorsAdministration = createReactClass({
const configuration = configurations.find(config => config.id === configAssignment.configuration_id);
let collectorStatus;
try {
const result = sidecar.node_details.status.collectors.find(c => c.name === collector.name);
const result = sidecar.node_details.status.collectors.find(c => c.collector_id === collector.id);
if (result) {
collectorStatus = result.status;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SidecarStatusFileList from './SidecarStatusFileList';
const SidecarStatus = createReactClass({
propTypes: {
sidecar: PropTypes.object.isRequired,
collectors: PropTypes.array.isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to a sidecar details page, I'm seeing the following in my JS console:

Warning: Failed prop type: The prop `collectors` is marked as required in `SidecarStatus`, but its value is `undefined`.
    in SidecarStatus (created by SidecarStatusPage)
    in SidecarStatusPage (created by ReactProxy)

},

componentDidMount() {
Expand Down Expand Up @@ -45,23 +46,23 @@ const SidecarStatus = createReactClass({
);
},

formatCollectorStatus(details) {
if (!details) {
formatCollectorStatus(details, collectors) {
if (!details || !collectors) {
return <p>Collectors status are currently unavailable. Please wait a moment and ensure the sidecar is correctly connected to the server.</p>;
}

if (!details.status) {
return <p>Did not receive collectors status, set the option <code>send_status: true</code> in the sidecar configuration to see this information.</p>;
}

const collectors = details.status.collectors;
if (collectors.length === 0) {
const collectorStatuses = details.status.collectors;
if (collectorStatuses.length === 0) {
return <p>There are no collectors configured in this sidecar.</p>;
}

const statuses = [];
collectors.forEach((status) => {
const collector = status.name;
collectorStatuses.forEach((status) => {
const collector = collectors.find(collector => collector.id === status.collector_id);

let statusMessage;
let statusBadge;
Expand All @@ -83,10 +84,12 @@ const SidecarStatus = createReactClass({
statusBadge = <i className="fa fa-question-circle fa-fw" />;
}

statuses.push(
<dt key={`${collector}-key`} className={statusClass}>{collector}</dt>,
<dd key={`${collector}-description`} className={statusClass}>{statusBadge}&ensp;{statusMessage}</dd>,
);
if (collector) {
statuses.push(
<dt key={`${collector}-key`} className={statusClass}>{collector.name}</dt>,
<dd key={`${collector}-description`} className={statusClass}>{statusBadge}&ensp;{statusMessage}</dd>,
);
}
});

return (
Expand All @@ -113,7 +116,7 @@ const SidecarStatus = createReactClass({
<Col md={12}>
<h2>Collectors status</h2>
<div className="top-margin">
{this.formatCollectorStatus(sidecar.node_details)}
{this.formatCollectorStatus(sidecar.node_details, this.props.collectors)}
</div>
</Col>
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SidecarStatusFileList extends React.Component {

render() {
var filterKeys = [];
var headers = ["Mo2dified", "Size", "Path"];
var headers = ["Modified", "Size", "Path"];

return (
<div>
Expand Down
11 changes: 9 additions & 2 deletions graylog2-web-interface/src/pages/SidecarStatusPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Routes from 'routing/Routes';
import SidecarStatus from 'components/sidecars/sidecars/SidecarStatus';

const { SidecarsActions } = CombinedProvider.get('Sidecars');
const { CollectorsActions } = CombinedProvider.get('Collectors');

class SidecarStatusPage extends React.Component {
static propTypes = {
Expand All @@ -25,6 +26,7 @@ class SidecarStatusPage extends React.Component {

componentDidMount() {
this.reloadSidecar();
this.reloadCollectors();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need to automatically reload collectors, or is it fine to only load them on page load? I guess the second option is fine, but want to double-check :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loading them once is good enough.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.interval = setInterval(this.reloadSidecar, 5000);
}

Expand All @@ -38,9 +40,14 @@ class SidecarStatusPage extends React.Component {
SidecarsActions.getSidecar(this.props.params.sidecarId).then(sidecar => this.setState({ sidecar }));
};

reloadCollectors = () => {
CollectorsActions.all().then(collectors => this.setState({ collectors }));
};

render() {
const sidecar = this.state.sidecar;
const isLoading = !sidecar;
const collectors = this.state.collectors;
const isLoading = !sidecar || !collectors;

if (isLoading) {
return <DocumentTitle title="Sidecar status"><Spinner /></DocumentTitle>;
Expand Down Expand Up @@ -72,7 +79,7 @@ class SidecarStatusPage extends React.Component {
</ButtonToolbar>
</PageHeader>

<SidecarStatus sidecar={sidecar} />
<SidecarStatus sidecar={sidecar} collectors={collectors} />
</span>
</DocumentTitle>
);
Expand Down