diff --git a/storage/remote/client.go b/storage/remote/client.go index 32f58af5b..d7838cb72 100644 --- a/storage/remote/client.go +++ b/storage/remote/client.go @@ -242,6 +242,14 @@ func (c *Client) GetProtoVersions(ctx context.Context) (string, error) { // Check for an error if httpResp.StatusCode != 200 { + if httpResp.StatusCode == 405 { + // If we get a 405 (MethodNotAllowed) error then it means the endpoint doesn't + // understand Remote Write 2.0, so we allow the lastRWHeader to be overwritten + // even if it is blank + // This will make subsequent sends use RemoteWrite 1.0 until the endpoint gives + // a response that confirms it can speak 2.0 + c.lastRWHeader = promHeader + } return promHeader, fmt.Errorf(httpResp.Status) } diff --git a/storage/remote/write.go b/storage/remote/write.go index 88a71cce4..0b79cfa2c 100644 --- a/storage/remote/write.go +++ b/storage/remote/write.go @@ -199,15 +199,12 @@ func (rws *WriteStorage) ApplyConfig(conf *config.Config) error { case Version1: // We use the standard value as there's no negotiation to be had case Version2: + rwFormat = Version2 // If this newer remote write format is enabled then we need to probe the remote server // to work out the desired protocol version and compressions // The value of the header is kept in the client so no need to see it here - rwFormat = Version2 - _, err := c.GetProtoVersions(context.Background()) // TODO(alexg) - better ctx to pass? - if err != nil { - // TODO(alexg) - Log an error based on this? - // TODO(alexg) - if we get 405 (MethodNotAllowed) then we should default to 1.0 (and downgrade rwFormat)? - } + _, _ = c.GetProtoVersions(context.Background()) + // TODO(alexg): Since they're never used should I remove the return values of GetProtoVersion()? } // Redacted to remove any passwords in the URL (that are