Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Commit

Permalink
fixes #1262 :
Browse files Browse the repository at this point in the history
 - mapping fields as well (keeps an indexable and raw versions of most of the strings)
 - added an alias in order to create to indexes in kibana
  • Loading branch information
AlmogBaku committed Sep 2, 2016
1 parent 2a7fbcf commit 4dee570
Show file tree
Hide file tree
Showing 2 changed files with 185 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common/elasticsearch/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func SaveDataIntoES(esClient *elastic.Client, indexName string, typeName string,
}
if !exists {
// Create a new index.
createIndex, err := esClient.CreateIndex(indexName).Do()
createIndex, err := esClient.CreateIndex(indexName).BodyString(mapping).Do()
if err != nil {
return err
}
Expand Down
184 changes: 184 additions & 0 deletions common/elasticsearch/mapping.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package elasticsearch

const mapping = `{
"aliases": {
"heapster-events": {
}
},
"mappings": {
"k8s-heapster": {
"properties": {
"MetricsName": {
"type": "string",
"index": "analyzed",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"MetricsTags": {
"properties": {
"container_base_image": {
"type": "string",
"index": "analyzed",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"container_name": {
"type": "string",
"index": "analyzed",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"host_id": {
"type": "string",
"index": "not_analyzed"
},
"hostname": {
"type": "string",
"index": "analyzed",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"labels": {
"type": "string",
"index": "analyzed",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"namespace_id": {
"type": "string",
"index": "not_analyzed"
},
"namespace_name": {
"type": "string",
"index": "not_analyzed"
},
"nodename": {
"type": "string",
"index": "analyzed",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"pod_id": {
"type": "string",
"index": "not_analyzed"
},
"pod_name": {
"type": "string",
"index": "analyzed",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"pod_namespace": {
"type": "string",
"index": "not_analyzed"
},
"resource_id": {
"type": "string",
"index": "not_analyzed"
},
"type": {
"type": "string",
"index": "not_analyzed"
}
}
},
"MetricsTimestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"MetricsValue": {
"properties": {
"value": {
"type": "long"
}
}
}
}
},
"events": {
"properties": {
"EventTags": {
"properties": {
"eventID": {
"type": "string",
"index": "not_analyzed"
},
"hostname": {
"type": "string",
"index": "analyzed",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"pod_id": {
"type": "string",
"index": "not_analyzed"
},
"pod_name": {
"type": "string",
"index": "analyzed",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
},
"EventTimestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"EventValue": {
"type": "string"
}
}
}
}
}`

0 comments on commit 4dee570

Please sign in to comment.